1<?php 2 3/* Copyright (c) 2017 Alex Killing <killing@leifos.de> Extended GPL, see docs/LICENSE */ 4 5namespace ILIAS\UI\Implementation\Component\Item; 6 7use ILIAS\UI\Component as C; 8use ILIAS\UI\Implementation\Component\ComponentHelper; 9 10/** 11 * Common interface to all items. 12 */ 13abstract class Item implements C\Item\Item 14{ 15 use ComponentHelper; 16 /** 17 * @var string|\ILIAS\UI\Component\Button\Shy|\ILIAS\UI\Component\Link\Link 18 */ 19 protected $title; 20 21 /** 22 * @var string 23 */ 24 protected $desc; 25 26 /** 27 * @var array 28 */ 29 protected $props; 30 31 /** 32 * @var \ILIAS\UI\Component\Dropdown\Standard 33 */ 34 protected $actions; 35 36 /** 37 * @var null|string|\ILIAS\UI\Component\Image\Image 38 */ 39 protected $lead = null; 40 41 /** 42 * Item constructor. 43 * @param \ILIAS\UI\Component\Button\Shy|\ILIAS\UI\Component\Link|string $title 44 */ 45 public function __construct($title) 46 { 47 if (!$title instanceof \ILIAS\UI\Component\Button\Shy && 48 !$title instanceof \ILIAS\UI\Component\Link\Link) { 49 $this->checkStringArg("title", $title); 50 } 51 $this->title = $title; 52 $this->props = []; 53 } 54 55 /** 56 * @inheritdoc 57 */ 58 public function getTitle() 59 { 60 return $this->title; 61 } 62 63 /** 64 * @inheritdoc 65 */ 66 public function withDescription(string $desc) : C\Item\Item 67 { 68 $this->checkStringArg("description", $desc); 69 $clone = clone $this; 70 $clone->desc = $desc; 71 return $clone; 72 } 73 74 /** 75 * @inheritdoc 76 */ 77 public function getDescription() 78 { 79 return $this->desc; 80 } 81 82 /** 83 * @inheritdoc 84 */ 85 public function withProperties(array $props) 86 { 87 $clone = clone $this; 88 $clone->props = $props; 89 return $clone; 90 } 91 92 /** 93 * @inheritdoc 94 */ 95 public function getProperties() 96 { 97 return $this->props; 98 } 99 100 /** 101 * @inheritdoc 102 */ 103 public function withActions(\ILIAS\UI\Component\Dropdown\Standard $actions) 104 { 105 $clone = clone $this; 106 $clone->actions = $actions; 107 return $clone; 108 } 109 110 /** 111 * @inheritdoc 112 */ 113 public function getActions() 114 { 115 return $this->actions; 116 } 117} 118