ServiceNotFoundException在CheckExceptionInValidReferenceBehaviorPass.php第58行中找到服务“异常”;应用程序管理页“;有依赖关系
当我转到url:时,我得到错误: CheckExceptionInValidReferenceBehaviorPass.php第58行中的ServiceNotFoundException:服务“app.admin.page”依赖于不存在的服务“sonata.admin.route.path\u info\u slashes” 路由.ymlServiceNotFoundException在CheckExceptionInValidReferenceBehaviorPass.php第58行中找到服务“异常”;应用程序管理页“;有依赖关系,php,symfony,sonata,Php,Symfony,Sonata,当我转到url:时,我得到错误: CheckExceptionInValidReferenceBehaviorPass.php第58行中的ServiceNotFoundException:服务“app.admin.page”依赖于不存在的服务“sonata.admin.route.path\u info\u slashes” 路由.yml admin_area: resource: "@SonataAdminBundle/Resources/config/routing/sonata_admin
admin_area:
resource: "@SonataAdminBundle/Resources/config/routing/sonata_admin.xml"
prefix: /sonata
cmf_routing:
# ...
dynamic:
# ...
persistence:
phpcr:
# ...
use_sonata_admin: false
服务.yml
services:
app.admin.page:
class: BrazBundle\Sonata\PageAdmin
arguments:
- ''
- BrazBundle\Document\Page
- 'SonataAdminBundle:CRUD'
tags:
- { name: sonata.admin, manager_type: doctrine_phpcr, group: 'Basic CMS', label: Page }
calls:
- [setRouteBuilder, ['@sonata.admin.route.path_info_slashes']]
app.admin.post:
class: BrazBundle\Sonata\PostAdmin
arguments:
- ''
- BrazBundle\Document\Post
- 'SonataAdminBundle:CRUD'
tags:
- { name: sonata.admin, manager_type: doctrine_phpcr, group: 'Basic CMS', label: 'Blog Posts' }
calls:
- [setRouteBuilder, ['@sonata.admin.route.path_info_slashes']]
config.yml
# app/config/config.yml
sonata_block:
default_contexts: [cms]
blocks:
# enable the SonataAdminBundle block
sonata.admin.block.admin_list:
contexts: [admin]
# ...
PageAdmin.php
<?php
namespace BrazBundle\Sonata;
use Sonata\DoctrinePHPCRAdminBundle\Admin\Admin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
class PageAdmin extends Admin
{
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->addIdentifier('title', 'text')
;
}
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->with('form.group_general')
->add('title', 'text')
->add('content', 'textarea')
->end()
;
}
public function prePersist($document)
{
$parent = $this->getModelManager()->find(null, '/cms/pages');
$document->setParentDocument($parent);
}
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper->add('title', 'doctrine_phpcr_string');
}
public function getExportFormats()
{
return array();
}
}
<?php
namespace BrazBundle\Sonata;
use Sonata\DoctrinePHPCRAdminBundle\Admin\Admin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
class PostAdmin extends PageAdmin
{
protected function configureFormFields(FormMapper $formMapper)
{
parent::configureFormFields($formMapper);
$formMapper
->with('form.group_general')
->add('date', 'date')
->end()
;
}
}
doctrine\u phpcr来自供应商/doctrine/phpcr bundle/doctrine/bundle/PHPCRBundle/Resources/config/phpcr.xml您添加了doctrine phpcr bundle吗?在我的AppKernel中,我不添加此bundle,然后您需要将此bundle添加到AppKernel中。doctrine\u phpcr来自供应商/doctrine/phpcr bundle/PHPCRBundle/PHPCRBundle/Resources/config/phpcr.xml您是否添加了捆绑包?在我的AppKernel中,我不添加此捆绑包,然后您需要将此捆绑包添加到AppKernel。
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new AppBundle\AppBundle(),
new BrazBundle\BrazBundle(),
new My\FrontendBundle\MyFrontendBundle(),
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
new FOS\UserBundle\FOSUserBundle(),
new UserBundle\UserBundle(),
// These are the other bundles the SonataAdminBundle relies on
new Sonata\CoreBundle\SonataCoreBundle(),
new Sonata\BlockBundle\SonataBlockBundle(),
new Knp\Bundle\MenuBundle\KnpMenuBundle(),
// And finally, the storage and SonataAdminBundle
new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
new Sonata\AdminBundle\SonataAdminBundle(),
//new CMSBundle\CMSBundle(),
);
if (in_array($this->getEnvironment(), array('dev', 'test'), true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}
return $bundles;
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
}
}