Search code examples
phpsymfonypropelsonata-adminsymfony-sonata

Sonata Propel Admin - Can't Find Service


I am trying to install and use the Sonata Admin Propel Package.
After basic setup it works, I can see the admin dashboard.
But when I try to define an admin service for a model I get a The service "sonata.admin.portfolio" has a dependency on a non-existent service "sonata.admin.manager.propel" error, which is true as I can't see it in the loaded services (using php app/console container:debug).

I installed it using composer;  
"require": {
    "propel/propel-bundle": "1.4.*",
    "sonata-project/propel-admin-bundle": "dev-master"
},

Registered it in AppKernel.php;

$bundles = array(
        new Propel\PropelBundle\PropelBundle(),
        // sonanta admin
        new Sonata\CoreBundle\SonataCoreBundle(),
        new Sonata\BlockBundle\SonataBlockBundle(),
        new Knp\Bundle\MenuBundle\KnpMenuBundle(),
        new Sonata\AdminBundle\SonataAdminBundle(),
);

My admin class for the model uses Sonata\PropelAdminBundle\Admin\Admin and is defined in admin.yml like;

services:
    sonata.admin.portfolio:
        class: Foo\CoreBundle\Admin\PortfolioAdmin
        tags:
            - { name: sonata.admin, manager_type: propel, group: "Content", label: "Portfolio" }
        arguments:
            - ~
            - Foo\CoreBundle\Model\Portfolio
            - FooCoreBundle:PortfolioAdmin
        calls:
            - [ setTranslationDomain, [FooCoreBundle]]

What have I missed?


Solution

  • Just a tiny mistake! You enabled the PropelBundle as necessary for the Propel ORM, but you did not enable the SonataPropelAdminBundle which integrates Propel with Sonata Admin.

    To do so, add this line to your AppKernel.php:

    new Sonata\PropelAdminBundle\SonataPropelAdminBundle(),
    

    Here are the installation instructions for Propel Admin