ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
DecoratedPagePartProvider.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use Closure;
31
38{
39 public const PURPOSE_TITLE = 'ptitle';
40 public const PURPOSE_SHORTTITLE = 'stitle';
41 public const PURPOSE_VIEWTITLE = 'vtitle';
42 public const PURPOSE_LOGO = 'plogo';
43 public const PURPOSE_RESPONSIVE_LOGO = 'prlogo';
44 public const PURPOSE_FAVICON = 'pfavicon';
45
52 public function __construct(private readonly PagePartProvider $original, private Closure $deco, private readonly string $purpose)
53 {
54 }
55
56 private function getDecoratedOrOriginal(string $purpose, Content|null|MetaBar|MainBar|Breadcrumbs|Image|string|Footer|TContainer $original)
57 {
58 if ($this->isDecorated($purpose)) {
59 $deco = $this->deco;
60
61 return $deco($original);
62 }
63
64 return $original;
65 }
66
67 private function isDecorated(string $purpose): bool
68 {
69 return $purpose === $this->purpose;
70 }
71
72
73 public function getContent(): ?Content
74 {
75 return $this->getDecoratedOrOriginal(Content::class, $this->original->getContent());
76 }
77
78
79 public function getMetaBar(): ?MetaBar
80 {
81 return $this->getDecoratedOrOriginal(MetaBar::class, $this->original->getMetaBar());
82 }
83
84
85 public function getMainBar(): ?MainBar
86 {
87 return $this->getDecoratedOrOriginal(MainBar::class, $this->original->getMainBar());
88 }
89
90
91 public function getBreadCrumbs(): ?Breadcrumbs
92 {
93 return $this->getDecoratedOrOriginal(Breadcrumbs::class, $this->original->getBreadCrumbs());
94 }
95
96
97 public function getLogo(): ?Image
98 {
99 return $this->getDecoratedOrOriginal(self::PURPOSE_LOGO, $this->original->getLogo());
100 }
101
102
103 public function getResponsiveLogo(): ?Image
104 {
105 return $this->getDecoratedOrOriginal(self::PURPOSE_RESPONSIVE_LOGO, $this->original->getResponsiveLogo());
106 }
107
108 public function getFaviconPath(): string
109 {
110 return $this->getDecoratedOrOriginal(self::PURPOSE_FAVICON, $this->original->getFaviconPath());
111 }
112
113
114 public function getSystemInfos(): array
115 {
116 return $this->original->getSystemInfos();
117 }
118
119
120 public function getFooter(): ?Footer
121 {
122 return $this->getDecoratedOrOriginal(Footer::class, $this->original->getFooter());
123 }
124
125
126 public function getTitle(): string
127 {
128 return $this->getDecoratedOrOriginal(self::PURPOSE_TITLE, $this->original->getTitle());
129 }
130
131
132 public function getShortTitle(): string
133 {
134 return $this->getDecoratedOrOriginal(self::PURPOSE_SHORTTITLE, $this->original->getShortTitle());
135 }
136
137
138 public function getViewTitle(): string
139 {
140 return $this->getDecoratedOrOriginal(self::PURPOSE_VIEWTITLE, $this->original->getViewTitle());
141 }
142
143 public function getToastContainer(): ?TContainer
144 {
145 return $this->getDecoratedOrOriginal(TContainer::class, $this->original->getToastContainer());
146 }
147}
getDecoratedOrOriginal(string $purpose, Content|null|MetaBar|MainBar|Breadcrumbs|Image|string|Footer|TContainer $original)
__construct(private readonly PagePartProvider $original, private Closure $deco, private readonly string $purpose)
DecoratedPagePartProvider constructor.
This describes the MainBar.
Definition: MainBar.php:34
This describes the MetaBar.
Definition: MetaBar.php:33