Swap to using App::DI instead of App::Instance()->get
This commit is contained in:
parent
7af588df43
commit
1353110c29
4 changed files with 16 additions and 4 deletions
|
|
@ -9,7 +9,7 @@ use jc21\CliTable;
|
|||
$timeAgo = new Westsworld\TimeAgo();
|
||||
|
||||
/** @var QueueService $queueService */
|
||||
$queueService = App::Instance()->get(QueueService::class);
|
||||
$queueService = App::DI(QueueService::class);
|
||||
|
||||
while(true) {
|
||||
$data = [];
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ echo "Starting {$workerClass} with {$threads} threads.\n";
|
|||
|
||||
if($threads == 1){
|
||||
/** @var AbstractQueueWorker $worker */
|
||||
$worker = App::Instance()->get($workerClass);
|
||||
$worker = App::DI($workerClass);
|
||||
$worker->setCliArguments($args);
|
||||
$worker->run();
|
||||
}else {
|
||||
|
|
@ -65,7 +65,7 @@ if($threads == 1){
|
|||
for ($i = 0; $i < $threads; $i++) {
|
||||
$fork->call(function () use ($workerClass, $args) {
|
||||
/** @var AbstractQueueWorker $worker */
|
||||
$worker = App::Instance()->get($workerClass);
|
||||
$worker = App::DI($workerClass);
|
||||
$worker->setCliArguments($args);
|
||||
$worker->run();
|
||||
});
|
||||
|
|
|
|||
12
src/App.php
12
src/App.php
|
|
@ -307,6 +307,18 @@ class App
|
|||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience function to get objects out of the Dependency Injection Container.
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function DI(string $key)
|
||||
{
|
||||
return self::Instance()->get($key);
|
||||
}
|
||||
|
||||
public function getApp()
|
||||
{
|
||||
return $this->app;
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ class EnvironmentHeadersOnResponse
|
|||
$response = $response->withJson($json, null, JSON_PRETTY_PRINT);
|
||||
} else {
|
||||
/** @var Twig $twig */
|
||||
$twig = App::Instance()->get('view');
|
||||
$twig = App::DI('view');
|
||||
$response->getBody()->rewind();
|
||||
$response = $twig->render($response, 'api/explorer.html.twig', [
|
||||
'page_name' => 'API Explorer',
|
||||
|
|
|
|||
Loading…
Reference in a new issue