Telegram\Bot\Api::setContainer PHP Method

setContainer() public static method

Set the IoC Container.
public static setContainer ( Illuminate\Contracts\Container\Container $container ) : void
$container Illuminate\Contracts\Container\Container Container instance
return void
    public static function setContainer(Container $container)
    {
        self::$container = $container;
    }

Usage Example

 /**
  * Initialize Telegram Bot SDK Library with Default Config.
  *
  * @param Application $app
  */
 protected function registerTelegram(Application $app)
 {
     $app->singleton(Api::class, function ($app) {
         $config = $app['config'];
         $telegram = new Api($config->get('telegram.bot_token', false), $config->get('telegram.async_requests', false), $config->get('telegram.http_client_handler', null));
         // Register Commands
         $telegram->addCommands($config->get('telegram.commands', []));
         // Check if DI needs to be enabled for Commands
         if ($config->get('telegram.inject_command_dependencies', false)) {
             $telegram->setContainer($app);
         }
         return $telegram;
     });
     $app->alias(Api::class, 'telegram');
 }
All Usage Examples Of Telegram\Bot\Api::setContainer