File modules/template_engine/components/html/component_set/SetComponent.class.php
Last commit: Wed May 15 00:55:16 2024 +0200 Jan Dankert New support for mapper in the Set-Component for better abstraction between UI and Actions
1 <?php 2 3 namespace template_engine\components\html\component_set; 4 5 use template_engine\components\html\Component; 6 use template_engine\element\PHPBlockElement; 7 use template_engine\element\Value; 8 9 class SetComponent extends Component 10 { 11 public $var; 12 public $value; 13 public $key; 14 public $mapper; 15 16 17 public function createElement() 18 { 19 $set = new PHPBlockElement(); 20 21 if ($this->value) 22 { 23 if ($this->key) 24 $set->inBlock = '$'.$set->varname($this->var).'= '.$this->addMapper($set->value($this->value).'['.((new Value($this->key))->render(Value::CONTEXT_PHP)).']').';'; 25 else 26 $set->inBlock = '$' . $set->varname($this->var) . '= ' . $this->addMapper($set->value($this->value) ). ';'; 27 } 28 else { 29 // Unset 30 $set->inBlock = 'unset($'.$set->varname($this->var).')'; 31 } 32 33 return $set; 34 } 35 36 private function addMapper($code) 37 { 38 if ( $this->mapper ) 39 return "O::map('".strtolower($this->mapper)."',".$code.")"; 40 else return $code; 41 } 42 }
Downloadmodules/template_engine/components/html/component_set/SetComponent.class.php
History Wed, 15 May 2024 00:55:16 +0200 Jan Dankert New support for mapper in the Set-Component for better abstraction between UI and Actions Wed, 14 Oct 2020 22:36:29 +0200 Jan Dankert Refactoring: Fixed the namespace in component classes, now the are able to be load by the standard autoloader. Wed, 14 Oct 2020 22:20:22 +0200 Jan Dankert Refactoring: Renamed component folders, because 'if' is no valid namespace fragment.