Change method of initializing container

parent c863f701
......@@ -49,10 +49,6 @@ class Kernel
$update = new Update($params->all(), $this->app->getBotUsername());
if ($response = $this->app->processUpdate($update)) {
return $response->isOk();
}
return $response;
return $this->app->processUpdate($update);
}
}
......@@ -28,7 +28,7 @@ use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use RegexIterator;
class Telegram extends Container
class Telegram
{
/**
* Version
......@@ -188,7 +188,7 @@ class Telegram extends Container
$this->bot_username = $bot_username;
}
$this->registerBaseBindings();
$this->registerContainer();
//Add default system commands path
$this->addCommandsPath(TB_BASE_COMMANDS_PATH . '/SystemCommands');
......@@ -197,17 +197,25 @@ class Telegram extends Container
}
/**
* Register the basic bindings into the container.
* Register the container.
*
* @return void
*/
protected function registerBaseBindings()
protected function registerContainer()
{
static::setInstance($this);
$this->container = Container::getInstance();
$this->instance('app', $this);
$this->container->instance(Telegram::class, $this);
}
$this->instance(Telegram::class, $this);
/**
* Get container instance.
*
* @return \Illuminate\Container\Container
*/
public function getContainer()
{
return $this->container;
}
/**
......@@ -364,7 +372,7 @@ class Telegram extends Container
}
/** @var \Longman\TelegramBot\Console\Kernel $kernel */
$kernel = $this->make(ConsoleKernel::class);
$kernel = $this->getContainer()->make(ConsoleKernel::class);
$response = $kernel->handle(Request::capture(), $limit, $timeout);
......@@ -374,7 +382,7 @@ class Telegram extends Container
/**
* Handle bot request from webhook
*
* @return bool
* @return \Longman\TelegramBot\Http\Response
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
......@@ -385,7 +393,7 @@ class Telegram extends Container
}
/** @var \Longman\TelegramBot\Http\Kernel $kernel */
$kernel = $this->make(Kernel::class);
$kernel = $this->getContainer()->make(Kernel::class);
$response = $kernel->handle(Request::capture());
......
......@@ -149,7 +149,7 @@ class TelegramTest extends TestCase
{
$telegram = new Telegram(self::$dummy_api_key, 'testbot');
$this->assertInstanceOf(\Illuminate\Container\Container::class, $telegram);
$this->assertInstanceOf(\Illuminate\Container\Container::class, $telegram->getContainer());
}
public function testCustom()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment