1<?php 2 3namespace plugin\struct\meta; 4 5/** 6 * Class Value 7 * 8 * Holds the value for a single "cell". That value may be an array for multi value columns 9 * 10 * @package plugin\struct\meta 11 */ 12class Value { 13 14 /** @var Column */ 15 protected $column; 16 17 /** @var array|int|string */ 18 protected $value; 19 20 /** 21 * Value constructor. 22 * 23 * @param Column $column 24 * @param array|int|string $value 25 */ 26 public function __construct(Column $column, $value) { 27 if($column->isMulti() && !is_array($value)) { 28 $value = array($value); 29 } 30 $this->value = $value; 31 $this->column = $column; 32 } 33 34 /** 35 * @return Column 36 */ 37 public function getColumn() { 38 return $this->column; 39 } 40 41 /** 42 * @return array|int|string 43 */ 44 public function getValue() { 45 return $this->value; 46 } 47 48 /** 49 * Render the value using the given renderer and mode 50 * 51 * @param \Doku_Renderer $R 52 * @param string $mode 53 */ 54 public function render(\Doku_Renderer $R, $mode) { 55 if($this->column->isMulti()) { 56 $this->column->getType()->renderMultiValue($this->value, $R, $mode); 57 } else { 58 $this->column->getType()->renderValue($this->value, $R, $mode); 59 } 60 } 61} 62