ILIAS  release_7 Revision v7.30-3-g800a261c036
DecoratedPagePartProvider.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
21
22use Closure;
29
36{
37 public const PURPOSE_TITLE = 'ptitle';
38 public const PURPOSE_SHORTTITLE = 'stitle';
39 public const PURPOSE_VIEWTITLE = 'vtitle';
40 public const PURPOSE_LOGO = 'plogo';
41 public const PURPOSE_RESPONSIVE_LOGO = 'prlogo';
42 public const PURPOSE_FAVICON = 'pfavicon';
43
47 private $original;
51 private $deco;
55 private $purpose;
56
63 public function __construct(PagePartProvider $original, Closure $deco, string $purpose)
64 {
65 $this->original = $original;
66 $this->deco = $deco;
67 $this->purpose = $purpose;
68 }
69
70 private function getDecoratedOrOriginal(string $purpose, $original)
71 {
72 if ($this->isDecorated($purpose)) {
74
75 return $deco($original);
76 }
77
78 return $original;
79 }
80
81 private function isDecorated(string $purpose) : bool
82 {
83 return $purpose === $this->purpose;
84 }
85
89 public function getContent() : ?Legacy
90 {
91 return $this->getDecoratedOrOriginal(Legacy::class, $this->original->getContent());
92 }
93
97 public function getMetaBar() : ?MetaBar
98 {
99 return $this->getDecoratedOrOriginal(MetaBar::class, $this->original->getMetaBar());
100 }
101
105 public function getMainBar() : ?MainBar
106 {
107 return $this->getDecoratedOrOriginal(MainBar::class, $this->original->getMainBar());
108 }
109
113 public function getBreadCrumbs() : ?Breadcrumbs
114 {
115 return $this->getDecoratedOrOriginal(Breadcrumbs::class, $this->original->getBreadCrumbs());
116 }
117
121 public function getLogo() : ?Image
122 {
123 return $this->getDecoratedOrOriginal(self::PURPOSE_LOGO, $this->original->getLogo());
124 }
125
126
127 public function getResponsiveLogo() : ?Image
128 {
129 return $this->getDecoratedOrOriginal(self::PURPOSE_RESPONSIVE_LOGO, $this->original->getResponsiveLogo());
130 }
131
132 public function getFaviconPath() : string
133 {
134 return $this->getDecoratedOrOriginal(self::PURPOSE_FAVICON, $this->original->getFaviconPath());
135 }
136
140 public function getSystemInfos() : array
141 {
142 return $this->original->getSystemInfos();
143 }
144
148 public function getFooter() : ?Footer
149 {
150 return $this->getDecoratedOrOriginal(Footer::class, $this->original->getFooter());
151 }
152
156 public function getTitle() : string
157 {
158 return $this->getDecoratedOrOriginal(self::PURPOSE_TITLE, $this->original->getTitle());
159 }
160
164 public function getShortTitle() : string
165 {
166 return $this->getDecoratedOrOriginal(self::PURPOSE_SHORTTITLE, $this->original->getShortTitle());
167 }
168
172 public function getViewTitle() : string
173 {
174 return $this->getDecoratedOrOriginal(self::PURPOSE_VIEWTITLE, $this->original->getViewTitle());
175 }
176}
An exception for terminatinating execution or to throw for unit testing.
__construct(PagePartProvider $original, Closure $deco, string $purpose)
DecoratedPagePartProvider constructor.
This describes the Footer.
Definition: Footer.php:16
This describes the MainBar.
Definition: MainBar.php:17
This describes the MetaBar.
Definition: MetaBar.php:15