1<?php 2/* Copyright (c) 2017 Nils Haagen <nils.haagen@concepts-and-training.de> Extended GPL, see docs/LICENSE */ 3 4namespace ILIAS\UI\Implementation\Component\Table; 5 6use ILIAS\UI\Component\Table as T; 7use ILIAS\UI\Implementation\Component\ComponentHelper; 8use ILIAS\UI\Implementation\Component\SignalGeneratorInterface; 9use ILIAS\UI\Implementation\Component\ViewControl\HasViewControls; 10 11class Presentation implements T\Presentation 12{ 13 use ComponentHelper; 14 use HasViewControls; 15 16 /** 17 * @var SignalGeneratorInterface 18 */ 19 protected $signal_generator; 20 21 /** 22 * @var string 23 */ 24 private $title; 25 26 /** 27 * @var \Closure 28 */ 29 private $row_mapping; 30 31 /** 32 * @var array<mixed> 33 */ 34 private $records; 35 36 /** 37 * @var array<string,mixed> 38 */ 39 private $environment; 40 41 42 43 public function __construct($title, array $view_controls, \Closure $row_mapping, SignalGeneratorInterface $signal_generator) 44 { 45 $this->checkStringArg("string", $title); 46 $this->title = $title; 47 $this->view_controls = $view_controls; 48 $this->row_mapping = $row_mapping; 49 $this->signal_generator = $signal_generator; 50 } 51 52 /** 53 * @inheritdoc 54 */ 55 public function getSignalGenerator() 56 { 57 return $this->signal_generator; 58 } 59 60 /** 61 * @inheritdoc 62 */ 63 public function withTitle($title) 64 { 65 $this->checkStringArg("string", $title); 66 $clone = clone $this; 67 $clone->title = $title; 68 ; 69 return $clone; 70 } 71 72 /** 73 * @inheritdoc 74 */ 75 public function getTitle() 76 { 77 return $this->title; 78 } 79 80 /** 81 * @inheritdoc 82 */ 83 public function withRowMapping(\Closure $row_mapping) 84 { 85 $clone = clone $this; 86 $clone->row_mapping = $row_mapping; 87 ; 88 return $clone; 89 } 90 91 /** 92 * @inheritdoc 93 */ 94 public function getRowMapping() 95 { 96 return $this->row_mapping; 97 } 98 99 /** 100 * @inheritdoc 101 */ 102 public function withEnvironment(array $environment) 103 { 104 $clone = clone $this; 105 $clone->environment = $environment; 106 return $clone; 107 } 108 109 /** 110 * @inheritdoc 111 */ 112 public function getEnvironment() 113 { 114 return $this->environment; 115 } 116 117 /** 118 * @inheritdoc 119 */ 120 public function withData(array $records) 121 { 122 $clone = clone $this; 123 $clone->records = $records; 124 ; 125 return $clone; 126 } 127 128 /** 129 * @inheritdoc 130 */ 131 public function getData() 132 { 133 return $this->records; 134 } 135} 136