thephpleague / tactician-bundle

Bundle to integrate Tactician with Symfony projects
MIT License
245 stars 43 forks source link

After upgrading symfony from 3.4 to 4.4(without flex) getting The \"tactician.commandbus\" 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 #132

Open vasanth-kumar-m-y opened 2 years ago

vasanth-kumar-m-y commented 2 years ago

Hi After updating symfony from 3.4 to 4.4(without flex) i am getting this error The \"tactician.commandbus\" 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

symfony (4.4.42) league/tactician-bundle (v1.4.0)

have injected commnd bus using DI in Controller

class MngmtController extends AbstractFOSRestController
{
   /**
     * @var CommandBus
     */
    private $commandBus;

    /**
     * @var CommandBus
     */
    private $mngmtCommandBus;

    /**
     * @var MngmtService
     */
    private $mngmtService;

    /**
     * @var LoggerInterface
     */
    private $logger;

    /**
     * @param ContainerInterface $container
     * @param CommandBus         $commandBus
     * @param CommandBus         $mngmtCommandBus
     * @param MngmtService       $mngmtService
     * @param LoggerInterface    $logger
     *
     * @DI\InjectParams({
     *     "container" = @DI\Inject("service_container"),
     *     "commandBus" = @DI\Inject("tactician.commandbus"),
     *     "mngmtCommandBus" = @DI\Inject("tactician.commandbus.mngmt"),
     *     "mngmtService" = @DI\Inject("app.services.mngmt_service"),
     *     "logger" = @DI\Inject("logger")
     * })
     */
    public function __construct(
        ContainerInterface $container,
        CommandBus $commandBus,
        CommandBus $mngmtCommandBus,
        MngmtService $mngmtService,
        LoggerInterface $logger
    ) {
        $this->container = $container;
        $this->commandBus = $commandBus;
        $this->mngmtCommandBus = $mngmtCommandBus;
        $this->mngmtService = $mngmtService;
        $this->logger = $logger;
    }

command and handler mapping in Handler

/**
 * Class UpdateMngmtCommandHandler.
 *
 * @DI\Service("app.update_mngmt_command_handler")
 * @DI\Tag("tactician.handler", attributes= {"command" = "AppBundle\CommandBus\UpdateMngmtCommand"})
 */
class MngmtCommandHandler {

middleware configuraion in config.yml

 tactician:
    commandbus:
        default:
            middleware:
                - tactician.middleware.locking
                - tactician.middleware.doctrine
                - tactician.middleware.command_handler
        mngmt:
            middleware:
                - tactician.middleware.locking
                - app.commandbus.middleware.lock_component
                - app.commandbus.middleware.transaction
                - app.commandbus.middleware.mngmt_block
                - tactician.middleware.command_handler