1
0
mirror of https://github.com/flarum/core.git synced 2025-08-17 13:54:18 +02:00

Remove a bunch of deprecated events

Use extenders instead!

Refs #1891.
This commit is contained in:
Franz Liedke
2020-04-27 22:04:08 +02:00
parent 7794546845
commit 7d1ef9d891
13 changed files with 6 additions and 467 deletions

View File

@@ -1,58 +0,0 @@
<?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\Console\Event;
use Illuminate\Console\Command;
use Illuminate\Contracts\Container\Container;
use Symfony\Component\Console\Application;
/**
* @deprecated
*/
class Configuring
{
/**
* @var Container
*/
public $app;
/**
* @var Application
*/
public $console;
/**
* @param Container $container
* @param Application $console
*/
public function __construct(Container $container, Application $console)
{
$this->app = $container;
$this->console = $console;
}
/**
* Add a console command to the flarum binary.
*
* @param Command|string $command
*/
public function addCommand($command)
{
if (is_string($command)) {
$command = $this->app->make($command);
}
if ($command instanceof Command) {
$command->setLaravel($this->app);
}
$this->console->add($command);
}
}

View File

@@ -9,12 +9,10 @@
namespace Flarum\Console;
use Flarum\Console\Event\Configuring;
use Flarum\Foundation\ErrorHandling\Registry;
use Flarum\Foundation\ErrorHandling\Reporter;
use Flarum\Foundation\SiteInterface;
use Illuminate\Contracts\Container\Container;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Container\Container;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\ConsoleEvents;
use Symfony\Component\Console\Event\ConsoleErrorEvent;
@@ -39,32 +37,20 @@ class Server
$console->add($command);
}
$this->extend($console); // deprecated
$this->handleErrors($console);
exit($console->run());
}
/**
* @deprecated
*/
private function extend(Application $console)
{
$container = \Illuminate\Container\Container::getInstance();
$this->handleErrors($container, $console);
$events = $container->make(Dispatcher::class);
$events->dispatch(new Configuring($container, $console));
}
private function handleErrors(Container $container, Application $console)
private function handleErrors(Application $console)
{
$dispatcher = new EventDispatcher();
$dispatcher->addListener(ConsoleEvents::ERROR, function (ConsoleErrorEvent $event) use ($container) {
$dispatcher->addListener(ConsoleEvents::ERROR, function (ConsoleErrorEvent $event) {
$container = Container::getInstance();
/** @var Registry $registry */
$registry = $container->make(Registry::class);
$error = $registry->handle($event->getError());
/** @var Reporter[] $reporters */