CheckExceptionOnInvalidReferenceBehaviorPass.php第58行中的ServiceNotFoundException服务" app.admin.page"有一个依赖

时间:2016-09-21 20:20:58

标签: php symfony sonata

当我转到网址时:http://localhost/symfony2/p1/web/app_dev.php/sonata/dashboard我收到错误:

  

CheckExceptionOnInvalidReferenceBehaviorPass.php第58行中的ServiceNotFoundException:服务" app.admin.page"依赖于不存在的服务" sonata.admin.route.path_info_slashes"。

的routing.yml

admin_area:
resource: "@SonataAdminBundle/Resources/config/routing/sonata_admin.xml"
prefix: /sonata

cmf_routing:
# ...
dynamic:
    # ...
    persistence:
        phpcr:
            # ...
            use_sonata_admin: false

services.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()
    ;
}
}

AppKernal.php

<?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');
}
}

0 个答案:

没有答案