1
0
mirror of https://github.com/flarum/core.git synced 2025-07-26 03:01:22 +02:00

Add console extender (#2057)

* Made the console command system extender-friendly

* Added console extender

* Added ConsoleTestCase to integration tests

* Added integration tests for console extender

* Marked event-based console extension system as deprecated

* Moved trimming command output of whitespace into superclass

* Renamed 'add' to 'command'

* Added special processing for laravel commands

* Code style fixes

* More style fixes

* Fixed $this->container
This commit is contained in:
Alexander Skvortsov
2020-04-03 13:38:54 -04:00
committed by GitHub
parent ca32879e1e
commit c84dd4d5bf
8 changed files with 204 additions and 15 deletions

View File

@@ -0,0 +1,37 @@
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Extend;
use Flarum\Extension\Extension;
use Illuminate\Contracts\Container\Container;
class Console implements ExtenderInterface
{
protected $addCommands = [];
/**
* Add a command to the console.
*
* @param string $command ::class attribute of command class, which must extend Flarum\Console\AbstractCommand
*/
public function command($command)
{
$this->addCommands[] = $command;
return $this;
}
public function extend(Container $container, Extension $extension = null)
{
$container->extend('flarum.console.commands', function ($existingCommands) {
return array_merge($existingCommands, $this->addCommands);
});
}
}