Elgg  Version 5.1
ViewColumn.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Views\TableColumn;
4 
6 
10 class ViewColumn implements TableColumn {
11 
15  private $heading;
16 
20  private $view;
21 
25  private $vars;
26 
34  public function __construct($view, $heading = null, $vars = []) {
35  $this->view = $view;
36  $this->vars = $vars;
37 
38  if (!is_string($heading)) {
39  $heading = elgg_echo("ViewColumn:view:$view");
40  }
41 
42  $this->heading = $heading;
43  }
44 
48  public function renderHeading() {
49  return $this->heading;
50  }
51 
55  public function renderCell($item, $type, $item_vars) {
56  $vars = array_merge($this->vars, [
57  'item' => $item,
58  'item_vars' => $item_vars,
59  'type' => $type,
60  ]);
61 
62  return elgg_view($this->view, $vars);
63  }
64 }
if(!$items) $item
Definition: delete.php:13
if(!$item instanceof ElggMenuItem) $item_vars
Definition: item.php:14
renderCell($item, $type, $item_vars)
{Render a value cell as HTML.Cell will be auto-wrapped with a TD element if the returned string doesn...
Definition: ViewColumn.php:55
renderHeading()
{Get the rendered heading cell as HTML.Cell will be auto-wrapped with a TH element if the returned st...
Definition: ViewColumn.php:48
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
$type
Definition: delete.php:22
Table column rendered by a view.
Definition: ViewColumn.php:10
elgg_view(string $view, array $vars=[], string $viewtype= '')
Return a parsed view.
Definition: views.php:177
__construct($view, $heading=null, $vars=[])
Constructor.
Definition: ViewColumn.php:34
A renderer for a column of table cells and a header.
Definition: TableColumn.php:7