2015-08-27 07:40:18 +08:00
|
|
|
<?php
|
2015-08-26 14:48:58 +08:00
|
|
|
/*
|
|
|
|
* This file is part of Flarum.
|
|
|
|
*
|
|
|
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Flarum\Events;
|
2015-07-18 21:29:47 +08:00
|
|
|
|
|
|
|
use Flarum\Support\ClientAction;
|
|
|
|
use Flarum\Support\ClientView;
|
2015-10-03 15:10:41 +08:00
|
|
|
use Flarum\Admin\Actions\ClientAction as AdminClientAction;
|
|
|
|
use Flarum\Forum\Actions\ClientAction as ForumClientAction;
|
2015-07-18 21:29:47 +08:00
|
|
|
|
2015-10-03 15:10:41 +08:00
|
|
|
class BuildClientView
|
2015-07-18 21:29:47 +08:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var ClientAction
|
|
|
|
*/
|
2015-07-20 16:38:28 +08:00
|
|
|
public $action;
|
2015-07-18 21:29:47 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var ClientView
|
|
|
|
*/
|
2015-07-20 16:38:28 +08:00
|
|
|
public $view;
|
2015-07-18 21:29:47 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
2015-07-20 16:38:28 +08:00
|
|
|
public $keys;
|
2015-07-18 21:29:47 +08:00
|
|
|
|
2015-10-03 15:10:41 +08:00
|
|
|
/**
|
|
|
|
* @param ClientAction $action
|
|
|
|
* @param ClientView $view
|
|
|
|
* @param array $keys
|
|
|
|
*/
|
|
|
|
public function __construct(ClientAction $action, ClientView $view, array &$keys)
|
|
|
|
{
|
|
|
|
$this->action = $action;
|
|
|
|
$this->view = $view;
|
|
|
|
$this->keys = &$keys;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isForum()
|
|
|
|
{
|
|
|
|
return $this->action instanceof ForumClientAction;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isAdmin()
|
|
|
|
{
|
|
|
|
return $this->action instanceof AdminClientAction;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addAssets($files)
|
2015-07-20 16:38:28 +08:00
|
|
|
{
|
2015-10-02 16:12:34 +08:00
|
|
|
$this->view->getAssets()->addFiles((array) $files);
|
2015-07-20 16:38:28 +08:00
|
|
|
}
|
|
|
|
|
2015-10-03 15:10:41 +08:00
|
|
|
public function addBootstrapper($bootstrapper)
|
2015-07-20 16:38:28 +08:00
|
|
|
{
|
2015-10-02 16:12:34 +08:00
|
|
|
$this->view->addBootstrapper($bootstrapper);
|
2015-07-31 18:43:13 +08:00
|
|
|
}
|
2015-08-04 15:46:34 +08:00
|
|
|
|
2015-10-03 15:10:41 +08:00
|
|
|
public function addTranslations(array $keys)
|
2015-08-04 15:46:34 +08:00
|
|
|
{
|
2015-10-02 16:12:34 +08:00
|
|
|
foreach ($keys as $key) {
|
|
|
|
$this->keys[] = $key;
|
2015-08-04 15:46:34 +08:00
|
|
|
}
|
|
|
|
}
|
2015-07-31 18:43:13 +08:00
|
|
|
}
|