mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-06 07:13:11 +08:00
26 lines
718 B
PHP
26 lines
718 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Shlinkio\Shlink\CLI\Factory;
|
|
|
|
use Psr\Container\ContainerInterface;
|
|
use Shlinkio\Shlink\Core\Options\AppOptions;
|
|
use Symfony\Component\Console\Application as CliApp;
|
|
use Symfony\Component\Console\CommandLoader\ContainerCommandLoader;
|
|
|
|
class ApplicationFactory
|
|
{
|
|
public function __invoke(ContainerInterface $container): CliApp
|
|
{
|
|
$config = $container->get('config')['cli'];
|
|
$appOptions = $container->get(AppOptions::class);
|
|
|
|
$commands = $config['commands'] ?? [];
|
|
$app = new CliApp($appOptions->name, $appOptions->version);
|
|
$app->setCommandLoader(new ContainerCommandLoader($container, $commands));
|
|
|
|
return $app;
|
|
}
|
|
}
|