我试图用mongodb配置sonatamediabundle,但在运行composer或清除缓存后出现此异常:
[errorException]可捕获的致命错误:传递给sonata\doctrineMongodbAdminBundle\model\modelmanager的参数1::\uu construct()必须是symfony\bridge\document\managerregistry的实例,给定的document\odm\mongodb\documentmanager的实例,在../vendor/sonata project/media bundle/ad中调用min/manager/doctrinemongodbmanager.php,第22行,定义在/users/interrobang/sites/aag/vendor/sonata project/doctrine mongodb admin bundle/sonata/doctrinemongodbadminbundle/model/modelmanager.php第39行
这是我的composer.json
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "Antenna": "src/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "~2.4",
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "~1.2",
"doctrine/mongodb-odm": "1.0.*@beta",
"doctrine/mongodb-odm-bundle": "3.0.*@beta",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~2.3",
"sensio/framework-extra-bundle": "~3.0",
"sensio/generator-bundle": "~2.3",
"incenteev/composer-parameter-handler": "~2.0",
"symfony/config": "~2.0",
"symfony/yaml": "~2.2",
"symfony/translation": "v2.4.5",
"friendsofsymfony/user-bundle": "~2.0@dev",
"jackalope/jackalope-mongodb": "dev-master@dev",
"sonata-project/admin-bundle": "dev-master@dev",
"sonata-project/doctrine-mongodb-admin-bundle": "dev-master",
"sonata-project/media-bundle": "dev-master@dev",
"jackalope/jackalope-doctrine-dbal": "dev-master@dev"
},
"scripts": {
"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
],
"post-update-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
]
},
"config": {
"bin-dir": "bin"
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "2.4-dev"
}
}
}
和我的config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
framework:
#esi: ~
#translator: { fallback: "en" }
translator: ~
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "en"
trusted_hosts: ~
trusted_proxies: ~
session:
# handler_id set to null will use default session handler from php.ini
handler_id: ~
fragments: ~
http_method_override: true
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
#form:
# resources:
# - 'CmfMediaBundle:Form:fields.html.twig'
# Assetic Configuration
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ AntennaArtGalleryBundle ]
#java: /usr/bin/java
filters:
cssrewrite: ~
#closure:
# jar: "%kernel.root_dir%/Resources/java/compiler.jar"
#yui_css:
# jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
sonata_block:
default_contexts: [cms]
blocks:
# Enable the SonataAdminBundle block
sonata.admin.block.admin_list:
contexts: [admin]
# Your other blocks
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
fos_user:
db_driver: mongodb
firewall_name: main
user_class: Antenna\ArtGalleryBundle\Document\User
registration:
form:
type: aag_admin_user_registration
# Mongo DB Doctrine Configuration
doctrine_mongodb:
connections:
default:
server: mongodb://localhost:27017
options: {}
default_database: test_database
document_managers:
default:
mappings:
#ApplicationSonataUserBundle: ~
#SonataUserBundle: ~
AntennaArtGalleryBundle: ~
FOSUserBundle: ~
#metadata_cache_driver:
# type: memcache
# class: Doctrine\Common\Cache\MemcacheCache
# host: localhost
# port: 11211
# instance_class: Memcache
sonata_media:
default_context: default
db_driver: doctrine_mongodb
contexts:
default:
providers:
- sonata.media.provider.dailymotion
- sonata.media.provider.youtube
- sonata.media.provider.image
- sonata.media.provider.file
formats:
small: { width: 100 , quality: 70}
big: { width: 500 , quality: 70}
cdn:
server:
path: /uploads/media
filesystem:
local:
directory: %kernel.root_dir%/../web/uploads/media
create: false
有什么想法吗?
最佳答案
您必须覆盖sonata.media.admin.media.manager
服务才能注入doctrine_mongodb
而不是doctrine_mongodb.odm.document_manager
因此,您必须将其添加到services.yml
文件中:
sonata.media.admin.media.manager:
class: Sonata\MediaBundle\Admin\Manager\DoctrineMongoDBManager
arguments: [@doctrine_mongodb, @sonata.media.manager.media]
这是一个修复,但只为orm(https://github.com/sonata-project/SonataMediaBundle/commit/9903f901db703ac441cbea18a1a8be1dc8c9c7e8)。
等待合并https://github.com/sonata-project/SonataMediaBundle/pull/611。