framework/src/Events/BuildClientView.php

74 lines
1.5 KiB
PHP
Raw Normal View History

2015-08-27 07:40:18 +08:00
<?php
/*
* 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;
use Flarum\Admin\Actions\ClientAction as AdminClientAction;
use Flarum\Forum\Actions\ClientAction as ForumClientAction;
2015-07-18 21:29:47 +08:00
class BuildClientView
2015-07-18 21:29:47 +08:00
{
/**
* @var ClientAction
*/
public $action;
2015-07-18 21:29:47 +08:00
/**
* @var ClientView
*/
public $view;
2015-07-18 21:29:47 +08:00
/**
* @var array
*/
public $keys;
2015-07-18 21:29:47 +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)
{
$this->view->getAssets()->addFiles((array) $files);
}
public function addBootstrapper($bootstrapper)
{
$this->view->addBootstrapper($bootstrapper);
}
public function addTranslations(array $keys)
{
foreach ($keys as $key) {
$this->keys[] = $key;
}
}
}