1<?php 2/* Copyright (c) 2017 Nils Haagen <nils.haagen@concepts-and-training.de> Extended GPL, see docs/LICENSE */ 3 4namespace ILIAS\UI\Component\Table; 5 6/** 7 * This describes a Presentation Table 8 */ 9interface Presentation extends \ILIAS\UI\Component\Component 10{ 11 12 /** 13 * Get a table like this with title $title. 14 * 15 * @param string $title 16 * @return \Presentation 17 */ 18 public function withTitle($title); 19 20 /** 21 * Get the title of the table. 22 * 23 * @return string 24 */ 25 public function getTitle(); 26 27 /** 28 * Get a table like this with these view controls. 29 * 30 * @param \ViewControl[] $view_controls 31 * @return \Presentation 32 */ 33 public function withViewControls(array $view_controls); 34 35 /** 36 * Get view controls to be shown in the header of the table. 37 * 38 * @return ILIAS\UI\Component\ViewControl[] 39 */ 40 public function getViewControls(); 41 42 /** 43 * Get a table like this with the closure $row_mapping. 44 * This closure is called by the renderer upon building a row from 45 * a record. The renderer will call the closure with these parameters: 46 * 47 * $row An instance of Component\Table\PresentationRow; 48 * fill the mutator according to your needs and the structure of 49 * your record. 50 * $record An element of the table's data. 51 * This is the actually variable part when rendering rows. 52 * $ui_factory You might, e.g., want a descriptive listing or and image 53 * within the content of the row. Use the UI-Factory to build it. 54 * $environment When you need auxillary classes or functions to properly render 55 * the data, this is the place to put it. 56 * 57 * In short: 58 * The closure MUST accept the following parameter 59 * \PresentationRow $row 60 * mixed $record 61 * \Factory $ui_factory 62 * mixed $environment 63 * The closure MUST return \PresentationRow 64 * 65 * @param \Closure $row_mapping 66 * @return \Presentation 67 */ 68 public function withRowMapping(\Closure $row_mapping); 69 70 71 /** 72 * Get the closure to construct row-entries with. 73 * 74 * @return \Closure 75 */ 76 public function getRowMapping(); 77 78 /** 79 * Add a list of additional things the mapping-closure needs for processing. 80 * These can be virtually anything. 81 * 82 * @param array<string,mixed> $environment 83 * @return \Presentation 84 */ 85 public function withEnvironment(array $environment); 86 87 /** 88 * Get an array of additionally needed elements to build a data-entry. 89 * 90 * @return array<string,mixed> 91 */ 92 public function getEnvironment(); 93 94 /** 95 * Fill a recordset into the table. 96 * All elements in $records MUST be processable by the mapping-closure. 97 * 98 * @param array<mixed> $records 99 * @return \Presentation 100 */ 101 public function withData(array $records); 102 103 /** 104 * Get the recordset of this table. 105 * All elements in $records MUST be processable by the mapping-closure. 106 * 107 * @return array<mixed> 108 */ 109 public function getData(); 110} 111