diff --git a/framework/core/src/Api/ApiServiceProvider.php b/framework/core/src/Api/ApiServiceProvider.php index 2d4afdf76..69c839561 100644 --- a/framework/core/src/Api/ApiServiceProvider.php +++ b/framework/core/src/Api/ApiServiceProvider.php @@ -13,7 +13,6 @@ use Flarum\Api\Controller\AbstractSerializeController; use Flarum\Api\Serializer\AbstractSerializer; use Flarum\Api\Serializer\BasicDiscussionSerializer; use Flarum\Api\Serializer\NotificationSerializer; -use Flarum\Event\ConfigureApiRoutes; use Flarum\Event\ConfigureNotificationTypes; use Flarum\Foundation\AbstractServiceProvider; use Flarum\Foundation\Application; @@ -120,9 +119,5 @@ class ApiServiceProvider extends AbstractServiceProvider $callback = include __DIR__.'/routes.php'; $callback($routes, $factory); - - $this->app->make('events')->dispatch( - new ConfigureApiRoutes($routes, $factory) - ); } } diff --git a/framework/core/src/Console/Event/Configuring.php b/framework/core/src/Console/Event/Configuring.php deleted file mode 100644 index 7c5679406..000000000 --- a/framework/core/src/Console/Event/Configuring.php +++ /dev/null @@ -1,58 +0,0 @@ -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); - } -} diff --git a/framework/core/src/Console/Server.php b/framework/core/src/Console/Server.php index e45fc68bf..98ef6b951 100644 --- a/framework/core/src/Console/Server.php +++ b/framework/core/src/Console/Server.php @@ -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 */ diff --git a/framework/core/src/Database/AbstractModel.php b/framework/core/src/Database/AbstractModel.php index d6f7b4ce6..182d33b3f 100644 --- a/framework/core/src/Database/AbstractModel.php +++ b/framework/core/src/Database/AbstractModel.php @@ -9,9 +9,6 @@ namespace Flarum\Database; -use Flarum\Event\ConfigureModelDates; -use Flarum\Event\ConfigureModelDefaultAttributes; -use Flarum\Event\GetModelRelationship; use Illuminate\Database\Eloquent\Model as Eloquent; use Illuminate\Database\Eloquent\Relations\Relation; use Illuminate\Support\Arr; @@ -84,11 +81,6 @@ abstract class AbstractModel extends Eloquent $this->attributes = array_merge($this->attributes, Arr::get(static::$defaults, $class, [])); } - // Deprecated in beta 13, remove in beta 14. - static::$dispatcher->dispatch( - new ConfigureModelDefaultAttributes($this, $this->attributes) - ); - $this->attributes = array_map(function ($item) { return is_callable($item) ? $item() : $item; }, $this->attributes); @@ -103,10 +95,6 @@ abstract class AbstractModel extends Eloquent */ public function getDates() { - static::$dispatcher->dispatch( - new ConfigureModelDates($this, $this->dates) - ); - $dates = $this->dates; foreach (array_merge(array_reverse(class_parents($this)), [static::class]) as $class) { @@ -157,11 +145,6 @@ abstract class AbstractModel extends Eloquent return $relation($this); } } - - // Deprecated, remove in beta 14 - return static::$dispatcher->until( - new GetModelRelationship($this, $name) - ); } /** diff --git a/framework/core/src/Event/AbstractConfigureRoutes.php b/framework/core/src/Event/AbstractConfigureRoutes.php deleted file mode 100644 index cca8a2a4b..000000000 --- a/framework/core/src/Event/AbstractConfigureRoutes.php +++ /dev/null @@ -1,90 +0,0 @@ -routes = $routes; - $this->route = $route; - } - - /** - * @param string $url - * @param string $name - * @param string $controller - */ - public function get($url, $name, $controller) - { - $this->route('get', $url, $name, $controller); - } - - /** - * @param string $url - * @param string $name - * @param string $controller - */ - public function post($url, $name, $controller) - { - $this->route('post', $url, $name, $controller); - } - - /** - * @param string $url - * @param string $name - * @param string $controller - */ - public function patch($url, $name, $controller) - { - $this->route('patch', $url, $name, $controller); - } - - /** - * @param string $url - * @param string $name - * @param string $controller - */ - public function delete($url, $name, $controller) - { - $this->route('delete', $url, $name, $controller); - } - - /** - * @param string $method - * @param string $url - * @param string $name - * @param string $controller - */ - protected function route($method, $url, $name, $controller) - { - $this->routes->$method($url, $name, $this->route->toController($controller)); - } -} diff --git a/framework/core/src/Event/ConfigureApiRoutes.php b/framework/core/src/Event/ConfigureApiRoutes.php deleted file mode 100644 index 3f17f293e..000000000 --- a/framework/core/src/Event/ConfigureApiRoutes.php +++ /dev/null @@ -1,17 +0,0 @@ -locales = $locales; - } - - /** - * Load language pack resources from the given directory. - * - * @param string $directory - */ - public function loadLanguagePackFrom($directory) - { - $name = $title = basename($directory); - - if (file_exists($manifest = $directory.'/composer.json')) { - $json = json_decode(file_get_contents($manifest), true); - - if (empty($json)) { - throw new RuntimeException("Error parsing composer.json in $name: ".json_last_error_msg()); - } - - $locale = Arr::get($json, 'extra.flarum-locale.code'); - $title = Arr::get($json, 'extra.flarum-locale.title', $title); - } - - if (! isset($locale)) { - throw new RuntimeException("Language pack $name must define \"extra.flarum-locale.code\" in composer.json."); - } - - $this->locales->addLocale($locale, $title); - - if (! is_dir($localeDir = $directory.'/locale')) { - throw new RuntimeException("Language pack $name must have a \"locale\" subdirectory."); - } - - if (file_exists($file = $localeDir.'/config.js')) { - $this->locales->addJsFile($locale, $file); - } - - if (file_exists($file = $localeDir.'/config.css')) { - $this->locales->addCssFile($locale, $file); - } - - foreach (new DirectoryIterator($localeDir) as $file) { - if ($file->isFile() && in_array($file->getExtension(), ['yml', 'yaml'])) { - $this->locales->addTranslations($locale, $file->getPathname()); - } - } - } -} diff --git a/framework/core/src/Event/ConfigureModelDates.php b/framework/core/src/Event/ConfigureModelDates.php deleted file mode 100644 index d110986a0..000000000 --- a/framework/core/src/Event/ConfigureModelDates.php +++ /dev/null @@ -1,50 +0,0 @@ -model = $model; - $this->dates = &$dates; - } - - /** - * @param string $model - * @return bool - */ - public function isModel($model) - { - return $this->model instanceof $model; - } -} diff --git a/framework/core/src/Event/ConfigureModelDefaultAttributes.php b/framework/core/src/Event/ConfigureModelDefaultAttributes.php deleted file mode 100644 index 3965147b5..000000000 --- a/framework/core/src/Event/ConfigureModelDefaultAttributes.php +++ /dev/null @@ -1,47 +0,0 @@ -model = $model; - $this->attributes = &$attributes; - } - - /** - * @param string $model - * @return bool - */ - public function isModel($model) - { - return $this->model instanceof $model; - } -} diff --git a/framework/core/src/Event/GetModelRelationship.php b/framework/core/src/Event/GetModelRelationship.php deleted file mode 100644 index 1c52eba2e..000000000 --- a/framework/core/src/Event/GetModelRelationship.php +++ /dev/null @@ -1,51 +0,0 @@ -model = $model; - $this->relationship = $relationship; - } - - /** - * @param string $model - * @param string $relationship - * @return bool - */ - public function isRelationship($model, $relationship) - { - return $this->model instanceof $model && $this->relationship === $relationship; - } -} diff --git a/framework/core/src/Forum/ForumServiceProvider.php b/framework/core/src/Forum/ForumServiceProvider.php index 788686207..5866a7289 100644 --- a/framework/core/src/Forum/ForumServiceProvider.php +++ b/framework/core/src/Forum/ForumServiceProvider.php @@ -9,7 +9,6 @@ namespace Flarum\Forum; -use Flarum\Event\ConfigureForumRoutes; use Flarum\Extension\Event\Disabled; use Flarum\Extension\Event\Enabled; use Flarum\Formatter\Formatter; @@ -186,10 +185,6 @@ class ForumServiceProvider extends AbstractServiceProvider $callback = include __DIR__.'/routes.php'; $callback($routes, $factory); - - $this->app->make('events')->dispatch( - new ConfigureForumRoutes($routes, $factory) - ); } /** diff --git a/framework/core/src/Locale/LocaleServiceProvider.php b/framework/core/src/Locale/LocaleServiceProvider.php index 255482ec5..e7de190c8 100644 --- a/framework/core/src/Locale/LocaleServiceProvider.php +++ b/framework/core/src/Locale/LocaleServiceProvider.php @@ -42,8 +42,6 @@ class LocaleServiceProvider extends AbstractServiceProvider $locales->addLocale($this->getDefaultLocale(), 'Default'); - event(new ConfigureLocales($locales)); - return $locales; });