无法在SonataAdminBundle中加载“filter”类型

时间:2012-06-13 08:18:00

标签: symfony symfony-sonata

我最近做了一个供应商/更新,现在我的奏鸣曲管理员因以下错误而被打破:

Symfony\Component\Form\Exception\FormException: Could not load type "filter" (uncaught exception) at /home/herman/WORK/bloomnet/sf/gaudeamus/vendor/symfony/src/Symfony/Component/Form/FormFactory.php line 383 

sonata admin之外的正常CRUD操作正常。索纳塔仪表板也行。问题是当我尝试显示文章列表或创建新文章时。在创建时,错误有点不同:

Could not load type "s4fd8521531280"

其中type是随机字符串,来自FormFactory.php中的同一行(383)

在出现错误之前,我安装了IvoryCKEditorBundle,但是当我在内核中禁用此包时,错误仍然存​​在

我的配置文件: routing.yml中

articles:
    resource: "@AcmeGaudeamusBundle/Controller/"
    type:     annotation
    prefix:   /    


admin:
    resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'
    prefix: /admin

_sonata_admin:
    resource: .
    type: sonata_admin
    prefix: /admin

config.yml

imports:
    - { resource: parameters.ini }
    - { resource: security.yml }

framework:
    #esi:             ~
    #translator:      { fallback: %locale% }
    secret:          %secret%
    charset:         UTF-8
    router:          { resource: "%kernel.root_dir%/config/routing.yml" }
    form:            true
    csrf_protection: true
    validation:      { enable_annotations: true }
    templating:      { engines: ['twig'] } #assets_version: SomeVersionScheme
    session:
        default_locale: %locale%
        auto_start:     true

# Twig Configuration
twig:
    debug:            %kernel.debug%
    strict_variables: %kernel.debug%

# Assetic Configuration
assetic:
    debug:          %kernel.debug%
    use_controller: false
    # java: /usr/bin/java
    filters:
        cssrewrite: ~
        # closure:
        #     jar: %kernel.root_dir%/java/compiler.jar
        # yui_css:
        #     jar: %kernel.root_dir%/java/yuicompressor-2.4.2.jar

# Doctrine Configuration
doctrine:
    dbal:
        driver:   %database_driver%
        host:     %database_host%
        port:     %database_port%
        dbname:   %database_name%
        user:     %database_user%
        password: %database_password%
        charset:  UTF8

    orm:
        auto_generate_proxy_classes: %kernel.debug%
        auto_mapping: true

# Swiftmailer Configuration
swiftmailer:
    transport: %mailer_transport%
    host:      %mailer_host%
    username:  %mailer_user%
    password:  %mailer_password%

jms_security_extra:
    secure_controllers:  true
    secure_all_services: false

services:
    admin.article:
        class: Acme\GaudeamusBundle\Admin\ArticleAdmin
        tags: 
            - { name: sonata.admin, manager_type: orm, group: Articles, label: Articles }
        arguments: [null, Acme\GaudeamusBundle\Entity\Article, SonataAdminBundle:CRUD]

    admin.menu:
        class: Acme\GaudeamusBundle\Admin\MenuAdmin
        tags: 
            - { name: sonata.admin, manager_type: orm, group: Menu, label: Menu }
        arguments: [null, Acme\GaudeamusBundle\Entity\Menu, SonataAdminBundle:CRUD]

# app/config/config.yml
sonata_block:
    default_contexts: [cms]
    blocks:
        sonata.admin.block.admin_list:
            contexts:   [admin]

        #sonata.admin_doctrine_orm.block.audit:
        #    contexts:   [admin]

        sonata.block.service.text:
        sonata.block.service.action:
        sonata.block.service.rss:

        # Some specific block from the SonataMediaBundle
        #sonata.media.block.media:
        #sonata.media.block.gallery:
        #sonata.media.block.feature_media:        

security.yml:

security:
    encoders:
        Symfony\Component\Security\Core\User\User: plaintext

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

    providers:
        in_memory:
            users:
                user:  { password: userpass, roles: [ 'ROLE_USER' ] }
                admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] }

    firewalls:
        dev:
            pattern:  ^/(_(profiler|wdt)|css|images|js)/
            security: false

        login:
            pattern:  ^/demo/secured/login$
            security: false

        secured_area:
            pattern:    ^/demo/secured/
            form_login:
                check_path: /demo/secured/login_check
                login_path: /demo/secured/login
            logout:
                path:   /demo/secured/logout
                target: /demo/
            #anonymous: ~
            #http_basic:
            #    realm: "Secured Demo Area"

    access_control:
        #- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
        #- { path: ^/_internal, roles: IS_AUTHENTICATED_ANONYMOUSLY, ip: 127.0.0.1 }

ArticleAdmin.php

<?php
namespace Acme\GaudeamusBundle\Admin;

use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Show\ShowMapper;
//use Sonata\AdminBundle\Validator\ErrorElement;

class ArticleAdmin extends Admin
{
    public function configureShowFields(ShowMapper $showMapper)
    {
        $showMapper
            ->add('title')
            ->add('intro')
            ->add('content')
            ->add('active')
            ->add('meta_title')
            ->add('meta_desc')
            ->add('meta_keywors')
            ->add('contact')
            ->add('menu')
        ;
    }

    public function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->with('General')
                ->add('title')
                ->add('intro')
                ->add('content')
                ->add('active')
                ->add('meta_title')
                ->add('meta_desc')
                ->add('contact')
                ->add('menu', NULL, 
                        array('empty_value' => 'Wybierz pozycję menu', 'required'  => false )
                )
            ->end()
        ;
    }

    public function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->addIdentifier('title')
            ->add('intro')
            ->add('active')
            ->add('meta_title')
            ->add('meta_desc')
            ->add('contact')
            ->add('menu')
            ->add('_action', 'actions', array(
                'actions' => array(
                    'edit' => array(),
                )
            ))
        ;
    }

    public function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper
            ->add('title')
            ->add('intro')
            ->add('active')
            ->add('meta_title')
            ->add('meta_desc')
            ->add('contact')
            ->add('menu')
        ;
    }
}

DEPS:

[symfony]
    git=http://github.com/symfony/symfony.git
    version=v2.0.14

[twig]
    git=http://github.com/fabpot/Twig.git
    version=v1.7.0

[monolog]
    git=http://github.com/Seldaek/monolog.git
    version=1.0.2

[doctrine-common]
    git=http://github.com/doctrine/common.git
    version=2.1.4

[doctrine-dbal]
    git=http://github.com/doctrine/dbal.git
    version=2.1.6

[doctrine]
    git=http://github.com/doctrine/doctrine2.git
    version=2.1.6

[swiftmailer]
    git=http://github.com/swiftmailer/swiftmailer.git
    version=v4.1.7

[assetic]
    git=http://github.com/kriswallsmith/assetic.git
    version=v1.0.3

[twig-extensions]
    git=http://github.com/fabpot/Twig-extensions.git

[metadata]
    git=http://github.com/schmittjoh/metadata.git
    version=1.0.0

[SensioFrameworkExtraBundle]
    git=http://github.com/sensio/SensioFrameworkExtraBundle.git
    target=/bundles/Sensio/Bundle/FrameworkExtraBundle
    version=origin/2.0

[JMSSecurityExtraBundle]
    git=http://github.com/schmittjoh/JMSSecurityExtraBundle.git
    target=/bundles/JMS/SecurityExtraBundle
    version=origin/1.0.x

[SensioDistributionBundle]
    git=http://github.com/sensio/SensioDistributionBundle.git
    target=/bundles/Sensio/Bundle/DistributionBundle
    version=origin/2.0

[SensioGeneratorBundle]
    git=http://github.com/sensio/SensioGeneratorBundle.git
    target=/bundles/Sensio/Bundle/GeneratorBundle
    version=origin/2.0

[AsseticBundle]
    git=http://github.com/symfony/AsseticBundle.git
    target=/bundles/Symfony/Bundle/AsseticBundle
    version=v1.0.1

[SonataAdminBundle]
    git=git://github.com/sonata-project/SonataAdminBundle.git
    target=/bundles/Sonata/AdminBundle
    version=origin/2.0

[SonataDoctrineORMAdminBundle]
    git=http://github.com/sonata-project/SonataDoctrineORMAdminBundle.git
    target=/bundles/Sonata/DoctrineORMAdminBundle
    version=origin/master

[SonataCacheBundle]
    git=http://github.com/sonata-project/SonataCacheBundle.git
    target=/bundles/Sonata/CacheBundle
    version=origin/2.0

[SonataBlockBundle]
    git=http://github.com/sonata-project/SonataBlockBundle.git
    target=/bundles/Sonata/BlockBundle
    version=origin/2.0

[SonatajQueryBundle]
    git=http://github.com/sonata-project/SonatajQueryBundle.git
    target=/bundles/Sonata/jQueryBundle

[KnpMenu]
    git=https://github.com/KnpLabs/KnpMenu.git

[KnpMenuBundle]
    git=https://github.com/KnpLabs/KnpMenuBundle.git
    target=bundles/Knp/Bundle/MenuBundle

[Exporter]
    git=http://github.com/sonata-project/exporter.git
    target=/exporter

[IvoryCKEditorBundle]
    git=http://github.com/egeloen/IvoryCKEditorBundle.git
    target=/bundles/Ivory/CKEditorBundle

有人有任何想法吗?

谢谢!

我找到了解决方案。并非所有供应商都来自2.0分支机构。我在deps中进行了更改并重新安装了供应商。

[symfony]
    git=http://github.com/symfony/symfony.git
    version=origin/2.0

[twig]
    git=http://github.com/fabpot/Twig.git
    version=v1.7.0


[monolog]
    git=http://github.com/Seldaek/monolog.git
    version=1.0.2

[doctrine-common]
    git=http://github.com/doctrine/common.git
    version=2.1.4

[doctrine-dbal]
    git=http://github.com/doctrine/dbal.git
    version=2.1.6

[doctrine]
    git=http://github.com/doctrine/doctrine2.git
    version=2.1.6

[swiftmailer]
    git=http://github.com/swiftmailer/swiftmailer.git
    version=v4.1.7

[assetic]
    git=http://github.com/kriswallsmith/assetic.git
    version=v1.0.3

[twig-extensions]
    git=http://github.com/fabpot/Twig-extensions.git

[metadata]
    git=http://github.com/schmittjoh/metadata.git
    version=1.0.0

[SensioFrameworkExtraBundle]
    git=http://github.com/sensio/SensioFrameworkExtraBundle.git
    target=/bundles/Sensio/Bundle/FrameworkExtraBundle
    version=origin/2.0

[JMSSecurityExtraBundle]
    git=http://github.com/schmittjoh/JMSSecurityExtraBundle.git
    target=/bundles/JMS/SecurityExtraBundle
    version=origin/1.0.x

[SensioDistributionBundle]
    git=http://github.com/sensio/SensioDistributionBundle.git
    target=/bundles/Sensio/Bundle/DistributionBundle
    version=origin/2.0

[SensioGeneratorBundle]
    git=http://github.com/sensio/SensioGeneratorBundle.git
    target=/bundles/Sensio/Bundle/GeneratorBundle
    version=origin/2.0

[AsseticBundle]
    git=http://github.com/symfony/AsseticBundle.git
    target=/bundles/Symfony/Bundle/AsseticBundle
    version=v1.0.1

[SonataAdminBundle]
    git=git://github.com/sonata-project/SonataAdminBundle.git
    target=/bundles/Sonata/AdminBundle
    version=origin/2.0

[SonataDoctrineORMAdminBundle]
    git=http://github.com/sonata-project/SonataDoctrineORMAdminBundle.git
    target=/bundles/Sonata/DoctrineORMAdminBundle
    version=origin/2.0

[SonataCacheBundle]
    git=http://github.com/sonata-project/SonataCacheBundle.git
    target=/bundles/Sonata/CacheBundle
    version=origin/2.0

[SonataBlockBundle]
    git=http://github.com/sonata-project/SonataBlockBundle.git
    target=/bundles/Sonata/BlockBundle
    version=origin/2.0

[SonatajQueryBundle]
    git=http://github.com/sonata-project/SonatajQueryBundle.git
    target=/bundles/Sonata/jQueryBundle

[KnpMenu]
    git=https://github.com/KnpLabs/KnpMenu.git

[KnpMenuBundle]
    git=https://github.com/KnpLabs/KnpMenuBundle.git
    target=bundles/Knp/Bundle/MenuBundle

[Exporter]
    git=http://github.com/sonata-project/exporter.git
    target=/exporter

[IvoryCKEditorBundle]
   git=http://github.com/egeloen/IvoryCKEditorBundle.git
   target=/bundles/Ivory/CKEditorBundle

1 个答案:

答案 0 :(得分:0)

这是一个解决方案: https://github.com/sonata-project/SonataAdminBundle/issues/831

您需要使用分支2.0