mirror of
https://github.com/flarum/core.git
synced 2025-10-15 08:55:53 +02:00
Refactor some APIs
This commit is contained in:
34
src/Extend/AdminClient.php
Normal file
34
src/Extend/AdminClient.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php namespace Flarum\Extend;
|
||||
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Flarum\Admin\Actions\IndexAction;
|
||||
|
||||
class AdminClient implements ExtenderInterface
|
||||
{
|
||||
protected $assets = [];
|
||||
|
||||
protected $translations = [];
|
||||
|
||||
public function assets($assets)
|
||||
{
|
||||
$this->assets = array_merge($this->assets, $assets);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function translations($keys)
|
||||
{
|
||||
$this->translations = array_merge($this->translations, $keys);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function extend(Container $container)
|
||||
{
|
||||
$container->make('events')->listen('Flarum\Admin\Events\RenderView', function ($event) {
|
||||
$event->assets->addFiles($this->assets);
|
||||
});
|
||||
|
||||
IndexAction::$translations = array_merge(IndexAction::$translations, $this->translations);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user