OneBot: Leantime 改造版源码(BOM/Univer 表格/AI 接管/品牌替换等)
This commit is contained in:
95
app/Core/Console/Application.php
Normal file
95
app/Core/Console/Application.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace Leantime\Core\Console;
|
||||
|
||||
use Illuminate\Console\Command as IlluminateCommand;
|
||||
use Illuminate\Console\Events\ArtisanStarting;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Support\ProcessUtils;
|
||||
use Leantime\Core\Events\DispatchesEvents;
|
||||
use Symfony\Component\Console\Command\Command as SymfonyCommand;
|
||||
use Symfony\Component\Console\Input\InputDefinition;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class Application extends \Illuminate\Console\Application
|
||||
{
|
||||
use DispatchesEvents;
|
||||
|
||||
protected $commandsLoaded = false;
|
||||
|
||||
public function __construct(Container $laravel, Dispatcher $events, $version)
|
||||
{
|
||||
|
||||
$parent = get_parent_class(\Illuminate\Console\Application::class);
|
||||
$parent::__construct('Leantime CLI (extends Laravel)', $version);
|
||||
|
||||
$this->laravel = $laravel;
|
||||
$this->events = $events;
|
||||
$this->setAutoExit(false);
|
||||
$this->setCatchExceptions(false);
|
||||
|
||||
$this->events->dispatch(new ArtisanStarting($this));
|
||||
|
||||
$this->bootstrap();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject the Laravel container into commands as they are registered.
|
||||
*
|
||||
* symfony/console 7.4 renamed add() to addCommand() and routes the lazy command-loader
|
||||
* path (Application::has() -> commandLoader->get()) through addCommand(), but
|
||||
* Illuminate\Console\Application only overrides the deprecated add() — the single place
|
||||
* setLaravel() is called. The result is that lazily-resolved #[AsCommand] commands run
|
||||
* with a null $laravel and fatal in Command::run(). Mirroring Illuminate's add() here on
|
||||
* addCommand() closes that gap for every registration path (add() delegates here too).
|
||||
*/
|
||||
public function addCommand(callable|SymfonyCommand $command): ?SymfonyCommand
|
||||
{
|
||||
if ($command instanceof IlluminateCommand) {
|
||||
$command->setLaravel($this->laravel);
|
||||
}
|
||||
|
||||
return parent::addCommand($command);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the current application.
|
||||
*
|
||||
* @return int 0 if everything went fine, or an error code
|
||||
*/
|
||||
public function doRun(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
// $this->setDomain($input);
|
||||
|
||||
self::dispatchEvent('beforeRun', ['application' => $this, 'input' => $input, 'output' => $output]);
|
||||
|
||||
/* wrapper for future use */
|
||||
return parent::doRun($input, $output);
|
||||
}
|
||||
|
||||
protected function getDefaultInputDefinition(): InputDefinition
|
||||
{
|
||||
$definition = parent::getDefaultInputDefinition();
|
||||
|
||||
$definition->addOption(new InputOption('--domain', null, InputOption::VALUE_OPTIONAL, 'Set domain for config'));
|
||||
|
||||
return $definition;
|
||||
|
||||
}
|
||||
|
||||
protected function bootstrap()
|
||||
{
|
||||
|
||||
foreach (static::$bootstrappers as $bootstrapper) {
|
||||
$bootstrapper($this);
|
||||
}
|
||||
}
|
||||
|
||||
public static function artisanBinary()
|
||||
{
|
||||
return ProcessUtils::escapeArgument('bin/leantime');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user