简体   繁体   English

Sonata管理员无法使用可排序的翻译工作

[英]Sonata admin can't get translation to work with sortable

I'm trying to configure translations using Gedmo, but Sortable behaviour I've enabled earlier seems to be getting in a way: 我正在尝试使用Gedmo配置翻译,但我之前启用的可排序行为似乎正在以某种方式:

An exception has been thrown during the rendering of a template ("The class 'Sonata\\TranslationBundle\\Model\\AbstractTranslatable' was not found in the chain configured namespaces Gedmo\\Translatable\\Entity, Gedmo\\Translator\\Entity, Gedmo\\Loggable\\Entity, Gedmo\\Tree\\Entity, AppBundle\\Entity, Vich\\UploaderBundle\\Entity, Sonata\\MediaBundle\\Entity, Application\\Sonata\\MediaBundle\\Entity, Sonata\\UserBundle\\Entity, Application\\Sonata\\UserBundle\\Entity, Sonata\\NewsBundle\\Entity, Sonata\\ClassificationBundle\\Entity, Application\\Sonata\\NewsBundle\\Entity, Application\\Sonata\\ClassificationBundle\\Entity, FOS\\UserBundle\\Model"). 在渲染模板期间抛出异常(“在链配置的命名空间中找不到类'Sonata \\ TranslationBundle \\ Model \\ AbstractTranslatable'Gedmo \\ Translatable \\ Entity,Gedmo \\ Translator \\ Entity,Gedmo \\ Loggable \\ Entity, Gedmo \\ Tree \\ Entity,AppBundle \\ Entity,Vich \\ UploaderBundle \\ Entity,Sonata \\ MediaBundle \\ Entity,Application \\ Sonata \\ MediaBundle \\ Entity,Sonata \\ UserBundle \\ Entity,Application \\ Sonata \\ UserBundle \\ Entity,Sonata \\ NewsBundle \\ Entity, Sonata \\ ClassificationBundle \\ Entity,Application \\ Sonata \\ NewsBundle \\ Entity,Application \\ Sonata \\ ClassificationBundle \\ Entity,FOS \\ UserBundle \\ Model“)。

The template throwing this exception is the one configured for handling of sortable buttons: 抛出此异常的模板是为处理可排序按钮而配置的模板:

/Pix/SortableBehaviorBundle/Resources/views/Default/_sort.html.twig (line 3) 

It fails on line 3 where it's attempting on setting last_position(object) 它在第3行失败,它正在尝试设置last_position(对象)

{% if admin.isGranted('EDIT', object) and admin.hasRoute('edit') %}
    {% set current_position = currentObjectPosition(object) %}
    {% set last_position    = lastPosition(object) %}
    {% set enable_top_bottom_buttons = field_description.options.actions.move.enable_top_bottom_buttons ?? true %}
    {% if enable_top_bottom_buttons and current_position < last_position %}
        <a class="btn btn-sm btn-default" href="{{ admin.generateObjectUrl('move', object, {'position': 'bottom'}) }}" title="{{ 'move_to_bottom'|trans }}">
            <i class="fa fa-angle-double-down"></i>

I'm following this translation tutorial: https://sonata-project.org/bundles/translation/master/doc/reference/orm.html 我正在关注这个翻译教程: https//sonata-project.org/bundles/translation/master/doc/reference/orm.html

Doctrine ORM Mappings: Doctrine ORM Mappings:

  orm:
    auto_generate_proxy_classes: '%kernel.debug%'
    entity_managers:
      default:
        naming_strategy: doctrine.orm.naming_strategy.underscore
        auto_mapping: true
        mappings:
          gedmo_translatable:
            type: annotation
            prefix: Gedmo\Translatable\Entity
            dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity"
            alias: GedmoTranslatable # (optional) it will default to the name set for the mapping
            is_bundle: false
          gedmo_translator:
            type: annotation
            prefix: Gedmo\Translator\Entity
            dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translator/Entity"
            alias: GedmoTranslator # (optional) it will default to the name set for the mapping
            is_bundle: false
          gedmo_loggable:
           type: annotation
           prefix: Gedmo\Loggable\Entity
           dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Loggable/Entity"
           alias: GedmoLoggable # (optional) it will default to the name set for the mapping
           is_bundle: false
          gedmo_tree:
            type: annotation
            prefix: Gedmo\Tree\Entity
            dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Entity"
            alias: GedmoTree # (optional) it will default to the name set for the mapping
            is_bundle: false

Dump of doctrine:mapping:info 学说转储:映射:信息

 Found 36 mapped entities:

 [OK]   Gedmo\Translatable\Entity\MappedSuperclass\AbstractTranslation
 [OK]   Gedmo\Translatable\Entity\Translation
 [OK]   Gedmo\Translatable\Entity\MappedSuperclass\AbstractPersonalTranslation
 [OK]   Gedmo\Translator\Entity\Translation
 [OK]   Gedmo\Loggable\Entity\MappedSuperclass\AbstractLogEntry
 [OK]   Gedmo\Loggable\Entity\LogEntry
 [OK]   Gedmo\Tree\Entity\MappedSuperclass\AbstractClosure
 [OK]   AppBundle\Entity\TeamBio
 [OK]   AppBundle\Entity\User
 [OK]   AppBundle\Entity\NewsItemSource
 [OK]   AppBundle\Entity\NewsItem
 [OK]   AppBundle\Entity\NewsItemTranslation
 [OK]   Sonata\MediaBundle\Entity\BaseMedia
 [OK]   Sonata\MediaBundle\Entity\BaseGallery
 [OK]   Sonata\MediaBundle\Entity\BaseGalleryHasMedia
 [OK]   Application\Sonata\MediaBundle\Entity\GalleryHasMedia
 [OK]   Application\Sonata\MediaBundle\Entity\Gallery
 [OK]   Application\Sonata\MediaBundle\Entity\Media
 [OK]   Sonata\UserBundle\Entity\BaseUser
 [OK]   Sonata\UserBundle\Entity\BaseGroup
 [OK]   Application\Sonata\UserBundle\Entity\Group
 [OK]   Application\Sonata\UserBundle\Entity\User
 [OK]   Sonata\NewsBundle\Entity\BaseComment
 [OK]   Sonata\NewsBundle\Entity\BasePost
 [OK]   Sonata\ClassificationBundle\Entity\BaseTag
 [OK]   Sonata\ClassificationBundle\Entity\BaseCollection
 [OK]   Sonata\ClassificationBundle\Entity\BaseCategory
 [OK]   Sonata\ClassificationBundle\Entity\BaseContext
 [OK]   Application\Sonata\NewsBundle\Entity\Comment
 [OK]   Application\Sonata\NewsBundle\Entity\Post
 [OK]   Application\Sonata\ClassificationBundle\Entity\Collection
 [OK]   Application\Sonata\ClassificationBundle\Entity\Category
 [OK]   Application\Sonata\ClassificationBundle\Entity\Tag
 [OK]   Application\Sonata\ClassificationBundle\Entity\Context
 [OK]   FOS\UserBundle\Model\Group
 [OK]   FOS\UserBundle\Model\User

Verify that you have loaded the SonataTranslationBundle in your AppKernel.php (symfony 2/3) or in your bundles.php (symfony 4). 确认您已在AppKernel.php (symfony 2/3)或bundles.php (symfony 4)中加载了SonataTranslationBundle。

Verify that you have enabled the gedmo extension in your symfony config: 确认您已在symfony配置中启用了gedmo扩展:

sonata_translation:
    gedmo:
        enabled: true

It looks like sonata translation s doctrine entity mapping for directory "sonata-project/translation-bundle/src/Model" is missing. 看起来像sonata翻译的教条实体映射目录“sonata-project / translation-bundle / src / Model”缺失。 Try adding it explicitly: 尝试明确添加它:

mappings:
    MyAdditionalSonataMapping:
              mapping: true
              type: annotation
              dir: "%kernel.root_dir%/../vendor/sonata-project/translation-bundle/src/Model"
              alias: 'Sonata\TranslationBundle\Model'
              prefix: 'Sonata\TranslationBundle\Model'
              is_bundle: false

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM