1: <?php
2:
3: namespace Charcoal\Ui;
4:
5: use InvalidArgumentException;
6:
7:
8: use Psr\Log\LoggerAwareInterface;
9: use Psr\Log\LoggerAwareTrait;
10: use Psr\Log\NullLogger;
11:
12: use Pimple\Container;
13:
14:
15: use Charcoal\Config\AbstractEntity;
16:
17:
18: use Charcoal\Translator\TranslatorAwareTrait;
19:
20:
21: use Charcoal\User\AuthAwareInterface;
22: use Charcoal\User\AuthAwareTrait;
23:
24:
25: use Charcoal\View\ViewableInterface;
26: use Charcoal\View\ViewableTrait;
27:
28:
29: use Charcoal\Ui\UiItemInterface;
30: use Charcoal\Ui\UiItemTrait;
31:
32: 33: 34: 35: 36:
37: abstract class AbstractUiItem extends AbstractEntity implements
38: AuthAwareInterface,
39: LoggerAwareInterface,
40: UiItemInterface
41: {
42: use AuthAwareTrait;
43: use LoggerAwareTrait;
44: use TranslatorAwareTrait;
45: use UiItemTrait;
46: use ViewableTrait;
47:
48: 49: 50: 51: 52:
53: private $active = true;
54:
55: 56: 57: 58: 59:
60: public function __construct(array $data = null)
61: {
62: if (!isset($data['logger'])) {
63: $data['logger'] = new NullLogger();
64: }
65: $this->setLogger($data['logger']);
66:
67: if (isset($data['container'])) {
68: $this->setDependencies($data['container']);
69: }
70: }
71:
72: 73: 74: 75: 76: 77:
78: public function setDependencies(Container $container)
79: {
80: $this->setTranslator($container['translator']);
81: $this->setAuthenticator($container['authenticator']);
82: $this->setAuthorizer($container['authorizer']);
83: }
84:
85: 86: 87: 88: 89: 90:
91: public function setActive($active)
92: {
93: $this->active = !!$active;
94:
95: return $this;
96: }
97:
98: 99: 100: 101: 102:
103: public function active()
104: {
105: return $this->active;
106: }
107: }
108: