Skip to content

Extending SortableAdminController, problem with constructor #91

@romazabelin

Description

@romazabelin

Hi. I create custom controller for class PromoPageAdmin and set it in the settings in admin.yaml

App\Admin\Action\Content\PromoPageAdmin:
        arguments: [ ~, App\Cms\Entity\Content\PromoPage, App\Cms\Controller\Content\PromoPageController ]
        calls:
            - setTranslationDomain: [ 'promo_page' ]
        tags:
            - { name: sonata.admin, manager_type: orm, label: promo_page_list }

And in controller

class PromoPageController extends SortableAdminController
{
    protected UploadHandler $uploadHandler;

    protected SerializerInterface $serializer;

    protected LoggerInterface $logger;

    protected EntityManagerInterface $entityManager;

public function __construct(
        PropertyAccessorInterface $accessor,
        PositionHandlerInterface $positionHandler,
        UploadHandler $uploadHandler, SerializerInterface $serializer, LoggerInterface $logger, EntityManagerInterface $entityManager
    )
    {
        $this->uploadHandler = $uploadHandler;
        $this->serializer = $serializer;
        $this->logger = $logger;
        $this->entityManager = $entityManager;

        parent::__construct($accessor, $positionHandler);
    }
}

But I got this error
Cannot autowire service "App\Cms\Controller\Content\PromoPageController": argument "$positionHandler" of method "__construct()" references interface "Runroom\SortableBehaviorBundle\Service\PositionHandlerInterface" but no such service exists. You should maybe alias this interface to one of these existing services: "Runroom\SortableBehaviorBundle\Service\ORMPositionHandler", "Runroom\SortableBehaviorBundle\Service\GedmoPositionHandler".

I tried add in service.yaml:
Runroom\SortableBehaviorBundle\Service\PositionHandlerInterface:

but next error:
Cannot instantiate interface Runroom\SortableBehaviorBundle\Service\PositionHandlerInterface

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions