Exemple #1
0
 /**
  * Return/Echo the current value of a Template Variable
  *
  * @note The PRESENCE of key is tested before return/echo it, not its value
  * @note Template Variable type since arrays and objects will always be returned
  *
  * @param string $tplVar]
  *
  *   Template Variable to be displayed or retrieved, accordingly to
  *   <strong>$_returnVariables</strong> property
  *
  * @return mixed|void
  *
  *   <p>
  *       If <strong>$_returnVariables</strong> property is set to TRUE
  *       or <strong>$tplVar</strong> points to an array or an Object,
  *       desired Template Variable will be returned
  *   </p>
  *
  *   <p>
  *       Otherwise, variable will be echoed and thus, nothing will
  *       be returned
  *   </p>
  *
  * @throws Next\View\ViewException
  *   Trying to access internal properties (prefixed with "_" without
  *   use their correct accessors
  *
  * @throws Next\View\ViewException
  *   Trying to get a undefined Template Variable
  */
 public function __get($tplVar)
 {
     if (property_exists($this, $tplVar)) {
         throw ViewException::forbiddenAccess();
     }
     if (!array_key_exists($tplVar, $this->_tplVars)) {
         throw ViewException::missingVariable($tplVar);
     }
     // Should we return?
     if ($this->_returnVariables !== FALSE || (is_array($this->_tplVars[$tplVar]) || is_object($this->_tplVars[$tplVar]))) {
         return $this->_tplVars[$tplVar];
     } else {
         // Or echo it?
         echo $this->_tplVars[$tplVar];
     }
 }