1<?php namespace ILIAS\GlobalScreen\Scope\MainMenu\Factory\Item; 2 3use Closure; 4use ILIAS\GlobalScreen\Identification\IdentificationInterface; 5use ILIAS\GlobalScreen\Identification\NullIdentification; 6use ILIAS\GlobalScreen\Scope\MainMenu\Factory\AbstractBaseItem; 7use ILIAS\GlobalScreen\Scope\MainMenu\Factory\hasAction; 8use ILIAS\GlobalScreen\Scope\MainMenu\Factory\hasContent; 9use ILIAS\GlobalScreen\Scope\MainMenu\Factory\hasSymbol; 10use ILIAS\GlobalScreen\Scope\MainMenu\Factory\hasTitle; 11use ILIAS\GlobalScreen\Scope\MainMenu\Factory\isChild; 12use ILIAS\GlobalScreen\Scope\MainMenu\Factory\isItem; 13use ILIAS\GlobalScreen\Scope\MainMenu\Factory\isParent; 14use ILIAS\GlobalScreen\Scope\MainMenu\Factory\isTopItem; 15use ILIAS\GlobalScreen\Scope\MainMenu\Factory\SymbolDecoratorTrait; 16use ILIAS\UI\Component\Component; 17use ILIAS\UI\Component\Symbol\Symbol; 18 19/** 20 * Class Lost 21 * @author Fabian Schmid <fs@studer-raimann.ch> 22 */ 23class Lost extends AbstractBaseItem implements hasContent, isTopItem, isParent, isChild, hasTitle, hasAction, hasSymbol 24{ 25 use SymbolDecoratorTrait; 26 /** 27 * @var isChild[] 28 */ 29 private $children = array(); 30 /** 31 * @var IdentificationInterface 32 */ 33 private $parent; 34 /** 35 * @var string 36 */ 37 private $title = ''; 38 39 /** 40 * @inheritDoc 41 */ 42 public function __construct(IdentificationInterface $provider_identification) 43 { 44 parent::__construct($provider_identification); 45 $this->parent = new NullIdentification(); 46 } 47 48 /** 49 * @inheritDoc 50 */ 51 public function withTitle(string $title) : hasTitle 52 { 53 $this->title = $title; 54 55 return $this; 56 } 57 58 /** 59 * @inheritDoc 60 */ 61 public function getTitle() : string 62 { 63 return $this->title; 64 } 65 66 /** 67 * @inheritDoc 68 */ 69 public function withContent(Component $ui_component) : hasContent 70 { 71 return $this; 72 } 73 74 /** 75 * @inheritDoc 76 */ 77 public function withContentWrapper(Closure $content_wrapper) : hasContent 78 { 79 return $this; 80 } 81 82 /** 83 * @inheritDoc 84 */ 85 public function getContent() : Component 86 { 87 global $DIC; 88 89 return $DIC->ui()->factory()->legacy(""); 90 } 91 92 /** 93 * @inheritDoc 94 */ 95 public function withParent(IdentificationInterface $identification) : isItem 96 { 97 $this->parent = $identification; 98 99 return $this; 100 } 101 102 /** 103 * @inheritDoc 104 */ 105 public function hasParent() : bool 106 { 107 return $this->parent instanceof isParent; 108 } 109 110 /** 111 * @inheritDoc 112 */ 113 public function getParent() : IdentificationInterface 114 { 115 return $this->parent; 116 } 117 118 /** 119 * @inheritDoc 120 */ 121 public function overrideParent(IdentificationInterface $identification) : isChild 122 { 123 $this->parent = $identification; 124 125 return $this; 126 } 127 128 /** 129 * @inheritDoc 130 */ 131 public function getChildren() : array 132 { 133 return $this->children; 134 } 135 136 /** 137 * @inheritDoc 138 */ 139 public function withChildren(array $children) : isParent 140 { 141 $this->children = $children; 142 143 return $this; 144 } 145 146 /** 147 * @inheritDoc 148 */ 149 public function appendChild(isChild $child) : isParent 150 { 151 $this->children[] = $child; 152 153 return $this; 154 } 155 156 /** 157 * @inheritDoc 158 */ 159 public function removeChild(isChild $child_to_remove) : isParent 160 { 161 $this->children = array_filter($this->children, static function (isItem $item) use ($child_to_remove) : bool { 162 return $item->getProviderIdentification()->serialize() !== $child_to_remove->getProviderIdentification()->serialize(); 163 }); 164 165 return $this; 166 } 167 168 /** 169 * @inheritDoc 170 */ 171 public function hasChildren() : bool 172 { 173 return count($this->children) > 0; 174 } 175 176 /** 177 * @inheritDoc 178 */ 179 public function withAction(string $action) : hasAction 180 { 181 // noting to to 182 return $this; 183 } 184 185 /** 186 * @inheritDoc 187 */ 188 public function getAction() : string 189 { 190 return "#"; 191 } 192 193 /** 194 * @inheritDoc 195 */ 196 public function withIsLinkToExternalAction(bool $is_external) : hasAction 197 { 198 // noting to to 199 return $this; 200 } 201 202 /** 203 * @inheritDoc 204 */ 205 public function isLinkWithExternalAction() : bool 206 { 207 return false; 208 } 209 210 /** 211 * @inheritDoc 212 */ 213 public function withSymbol(Symbol $symbol) : hasSymbol 214 { 215 return $this; 216 } 217 218 /** 219 * @inheritDoc 220 */ 221 public function getSymbol() : Symbol 222 { 223 return null; 224 } 225 226 /** 227 * @inheritDoc 228 */ 229 public function hasSymbol() : bool 230 { 231 return false; 232 } 233} 234