Skip to content

CoreShop 4 - Extending Frontend Controllers #2635

@Stefan-JustMe69-SQ

Description

@Stefan-JustMe69-SQ
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no

I followed documentation
https://docs.coreshop.org/CoreShop/Development/Frontend_Bundle/
an created own class TemplateConfigurator

<?php

declare(strict_types=1);

namespace FrontendBundle\CoreShop\TemplateConfigurator;

use CoreShop\Bundle\FrontendBundle\TemplateConfigurator\TemplateConfiguratorInterface;

class TemplateConfigurator implements TemplateConfiguratorInterface
{
    public function findTemplate(string $templateName): string
    {
        return sprintf('coreshop/%s.twig', $templateName);
    }
}


    FrontendBundle\CoreShop\TemplateConfigurator\TemplateConfigurator:
        decorates: 'CoreShop\Bundle\FrontendBundle\TemplateConfigurator\TemplateConfigurator'
        public: true

I created controller IndexController and followed description in
https://docs.coreshop.org/CoreShop/Development/Frontend_Bundle/Controllers
and created controller and configuration as described

my class:

<?php

declare(strict_types=1);

namespace FrontendBundle\CoreShop\Controller;

use CoreShop\Bundle\FrontendBundle\Controller\FrontendController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class IndexController extends FrontendController
{

    public function indexAction(Request $request): Response
    {
        return $this->render($this->getTemplateConfigurator()->findTemplate('Index/index.html'));
    }
}

my configs:

    FrontendBundle\CoreShop\Controller\IndexController:
        public: true
        arguments:
            - '@service_container'

core_shop_frontend:
    controllers:
        index: FrontendBundle\CoreShop\Controller\IndexController

I'm getting error:

The "CoreShop\Bundle\FrontendBundle\TemplateConfigurator\TemplateConfiguratorInterface" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.

How to fix that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions