TYPO3 API  SVNRelease
ArrayNode.php
Go to the documentation of this file.
00001 <?php
00002 
00003 /*                                                                        *
00004  * This script belongs to the FLOW3 package "Fluid".                      *
00005  *                                                                        *
00006  * It is free software; you can redistribute it and/or modify it under    *
00007  * the terms of the GNU Lesser General Public License as published by the *
00008  * Free Software Foundation, either version 3 of the License, or (at your *
00009  * option) any later version.                                             *
00010  *                                                                        *
00011  * This script is distributed in the hope that it will be useful, but     *
00012  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
00013  * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
00014  * General Public License for more details.                               *
00015  *                                                                        *
00016  * You should have received a copy of the GNU Lesser General Public       *
00017  * License along with the script.                                         *
00018  * If not, see http://www.gnu.org/licenses/lgpl.html                      *
00019  *                                                                        *
00020  * The TYPO3 project - inspiring people to share!                         *
00021  *                                                                        */
00022 
00023 /**
00024  * Array Syntax Tree Node. Handles JSON-like arrays.
00025  *
00026  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
00027  */
00028 class Tx_Fluid_Core_Parser_SyntaxTree_ArrayNode extends Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode {
00029 
00030     /**
00031      * An associative array. Each key is a string. Each value is either a literal, or an AbstractNode.
00032      * @var array
00033      */
00034     protected $internalArray = array();
00035 
00036     /**
00037      * Constructor.
00038      *
00039      * @param array $internalArray Array to store
00040      * @author Sebastian Kurfürst <sebastian@typo3.org>
00041      */
00042     public function __construct($internalArray) {
00043         $this->internalArray = $internalArray;
00044     }
00045 
00046     /**
00047      * Evaluate the array and return an evaluated array
00048      *
00049      * @param Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext
00050      * @return array An associative array with literal values
00051      * @author Sebastian Kurfürst <sebastian@typo3.org>
00052      * @author Bastian Waidelich <bastian@typo3.org>
00053      */
00054     public function evaluate(Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext) {
00055         $arrayToBuild = array();
00056         foreach ($this->internalArray as $key => $value) {
00057             if ($value instanceof Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode) {
00058                 $arrayToBuild[$key] = $value->evaluate($renderingContext);
00059             } else {
00060                 // TODO - this case should not happen!
00061                 $arrayToBuild[$key] = $value;
00062             }
00063         }
00064         return $arrayToBuild;
00065     }
00066 }
00067 
00068 ?>