BoShurik/TelegramBotBundle

Created a telegram command which depends on the service

whdigger opened this issue · 4 comments

I am trying to create a command which depends on the service and the service depends on redis.
Autowire is specified in the `config/services.yaml ' settings

services:
    # default configuration for services in *this* file
    _defaults:
        autowire: true
        autoconfigure: true
        bind:
          Redis $redisDefault: '@snc_redis.default'

The service code is as follows

class VerificationCode
{
    /**
     * @var \Redis
     */
    protected $redis;

    /**
     * @param \Redis $redis
     */
    protected function __constructor(\Redis $redisDefault)
    {
        $this->redis = $redisDefault;
    }
}

The command code for telegram is as follows

class VerificationCodeCommand extends AbstractCommand implements PublicCommandInterface
{
    protected $verificationCode;

    /**
     * VerificationCodeCommand constructor.
     */
    public function __construct(VerificationCode $verificationCode)
    {
        $this->verificationCode = $verificationCode;
    }
}

The cache that symfony generates is not correct, and no errors are thrown during the call, but the VerificationCode constructor does not work.

Symfony cache code:

namespace ContainerDqZ4H22;

use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;

/**
 * @internal This class has been auto-generated by the Symfony Dependency Injection Component.
 */
class getBoshurikTelegramBot_Command_ListenerService extends App_KernelDevDebugContainer
{
    /**
     * Gets the private 'boshurik_telegram_bot.command.listener' shared service.
     *
     * @return \BoShurik\TelegramBotBundle\EventListener\CommandListener
     */
    public static function do($container, $lazyLoad = true)
    {
        include_once \dirname(__DIR__, 4).'/vendor/boshurik/telegram-bot-bundle/src/EventListener/CommandListener.php';
        include_once \dirname(__DIR__, 4).'/vendor/boshurik/telegram-bot-bundle/src/Telegram/Command/CommandRegistry.php';
        include_once \dirname(__DIR__, 4).'/vendor/boshurik/telegram-bot-bundle/src/Telegram/Command/CommandInterface.php';
        include_once \dirname(__DIR__, 4).'/vendor/boshurik/telegram-bot-bundle/src/Telegram/Command/AbstractCommand.php';
        include_once \dirname(__DIR__, 4).'/vendor/boshurik/telegram-bot-bundle/src/Telegram/Command/PublicCommandInterface.php';
        include_once \dirname(__DIR__, 4).'/src/Model/Telegram/Commands/VerificationCodeCommand.php';
        include_once \dirname(__DIR__, 4).'/src/Model/Telegram/Service/VerificationCode.php';

        $a = new \BoShurik\TelegramBotBundle\Telegram\Command\CommandRegistry();
        $a->addCommand(new \App\Model\Telegram\Commands\VerificationCodeCommand(($container->privates['App\\Model\\Telegram\\Service\\VerificationCode'] ?? ($container->privates['App\\Model\\Telegram\\Service\\VerificationCode'] = new \App\Model\Telegram\Service\VerificationCode()))));

        return $container->privates['boshurik_telegram_bot.command.listener'] = new \BoShurik\TelegramBotBundle\EventListener\CommandListener(($container->privates['TelegramBot\\Api\\BotApi'] ?? $container->load('getBotApiService')), $a);
    }
}

Tell me plz what could be the problem?
Thnx

- protected function __constructor(\Redis $redisDefault)
+ public function __construct(\Redis $redisDefault)

Sorry, I was experimenting with the error appearing. No errors appear on the private and protected constructor. The public constructor doesn't help.

__constructor - is not a magic method

Thank you very much, just now I noticed a typo