Skip to content
Advertisement

Error at login: This repository can be attached only to ORM sortable listener

I am currently verifying the operation by upgrading to Symfony 4.0. When I tried to log in by entering my ID and password, the following error message appeared.
Is there anything you can think of?
StofDoctrine Extensions wasn’t used until Symfony 3.4.

Error message

This repository can be attached only to ORM sortable listener

Code

BaseRepository.php

use GedmoSortableEntityRepositorySortableRepository;

/**
 * Repository base class
 */
class BaseRepository extends SortableRepository
{

    /**
      * Get an expression that converts gender to a sortable value
      *
      * Add the obtained expression to the SELECT clause and specify the alias specified in $ alias in the ORDER BY clause.
     *
     * @param $sex sex
     * @param $alias Another name for the converted value
     */
    public function toSortableSex($sex, $alias)
    {
        return "case {$sex} when 0 then 1 when 1 then 0 else {$sex} end as hidden {$alias}";
    }
}

config/package/doctrine.yaml

doctrine:
    orm:
        auto_generate_proxy_classes: true
        naming_strategy: doctrine.orm.naming_strategy.underscore
        auto_mapping: true
        mappings:
            App:
                is_bundle: false
                type: annotation
                dir: '%%kernel.project_dir%%/src/Entity'
                prefix: 'AppEntity'
                alias: App


var/log/dev.log

[2021-01-25 10:43:31] request.INFO: Matched route "app_security_login". {"route":"app_security_login","route_parameters":{"_controller":"App\Controller\SecurityController::loginAction","_route":"app_security_login"},"request_uri":"http://192.168.33.70/admin/login","method":"GET"} []
[2021-01-25 10:43:31] security.INFO: Populated the TokenStorage with an anonymous Token. [] []
[2021-01-25 10:43:31] php.INFO: User Deprecated: The "SensioBundleFrameworkExtraBundleConfigurationRoute" annotation is deprecated since version 5.2. Use "SymfonyComponentRoutingAnnotationRoute" instead. {"exception":"[object] (ErrorException(code: 0): User Deprecated: The "Sensio\Bundle\FrameworkExtraBundle\Configuration\Route" annotation is deprecated since version 5.2. Use "Symfony\Component\Routing\Annotation\Route" instead. at /home/vagrant/Symfony2/vendor/sensio/framework-extra-bundle/Configuration/Route.php:16)"} []
[2021-01-25 10:43:31] translation.WARNING: Translation not found. {"id":"This repository can be attached only to ORM sortable listener","domain":"messages","locale":"en"} []
[2021-01-25 10:43:31] php.INFO: User Deprecated: Creating DoctrineORMMappingUnderscoreNamingStrategy without making it number aware is deprecated and will be removed in Doctrine ORM 3.0. {"exception":"[object] (ErrorException(code: 0): User Deprecated: Creating Doctrine\ORM\Mapping\UnderscoreNamingStrategy without making it number aware is deprecated and will be removed in Doctrine ORM 3.0. at /home/vagrant/Symfony2/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/UnderscoreNamingStrategy.php:66)"} []
[2021-01-25 10:43:31] request.INFO: Matched route "_wdt". {"route":"_wdt","route_parameters":{"_controller":"web_profiler.controller.profiler:toolbarAction","token":"178c6f","_route":"_wdt"},"request_uri":"http://192.168.33.70/_wdt/178c6f","method":"GET"} []

Version
Symfony 4.0.15
PHP7.4
gedmo/doctrine-extensions 2.3.12

Advertisement

Answer

I wasn’t moving doctrine_extensions.yaml from app/config/ to config/packages/. I apologize for the inconvenience.

doctrine_extensions.yaml

# services to handle doctrine extensions
# import it in config.yml
services:
    # Doctrine Extension listeners to handle behaviors
    gedmo.listener.softdeleteable:
        class: GedmoSoftDeleteableSoftDeleteableListener
        calls:
            - [ setAnnotationReader, [ "@annotation_reader" ] ]
        tags:
            - { name: doctrine.event_subscriber, connection: default }

    gedmo.listener.sortable:
        class: GedmoSortableSortableListener
        calls:
            - [ setAnnotationReader, [ "@annotation_reader" ] ]
        tags:
            - { name: doctrine.event_subscriber, connection: default }


User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement