#StackBounty: #php #symfony #translation #sonata-admin Sonata admin can't get translation to work with sortable

Bounty: 200

I’m trying to configure translations using Gedmo, but Sortable behaviour I’ve enabled earlier seems to be getting in a way:

An exception has been thrown during the rendering of a template (“The
class ‘SonataTranslationBundleModelAbstractTranslatable’ was not
found in the chain configured namespaces GedmoTranslatableEntity,
GedmoTranslatorEntity, GedmoLoggableEntity, GedmoTreeEntity,
AppBundleEntity, VichUploaderBundleEntity,
SonataMediaBundleEntity, ApplicationSonataMediaBundleEntity,
SonataUserBundleEntity, ApplicationSonataUserBundleEntity,
SonataNewsBundleEntity, SonataClassificationBundleEntity,
ApplicationSonataNewsBundleEntity,
ApplicationSonataClassificationBundleEntity,
FOSUserBundleModel”).

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)

{% 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

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: GedmoTranslatableEntity
            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: GedmoTranslatorEntity
            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: GedmoLoggableEntity
           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: GedmoTreeEntity
            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


Get this bounty!!!

Leave a Reply