Beispiel #1
0
 public function setPath(array &$aPath, $mValue = null, $bRef = false)
 {
     $mCurrent =& $this->aArray;
     $bNULL = is_null($mValue);
     do {
         $sKey = current($aPath);
         //echo is_object($mCurrent) ? get_class($mCurrent) : print_r($mCurrent);
         if ($mCurrent instanceof core\argument) {
             return $mCurrent->setPath($aPath, $mValue, $bRef);
         } else {
             if (!is_array($mCurrent)) {
                 $this->launchException("Cannot set value to : " . \Sylma::show($mCurrent), get_defined_vars());
             }
         }
         if (!array_key_exists($sKey, $mCurrent)) {
             $mCurrent[$sKey] = array();
         }
         $mPrevious =& $mCurrent;
         $mCurrent =& $mCurrent[$sKey];
     } while (next($aPath) !== false);
     if (current($aPath) !== false) {
         $this->throwException(sprintf('Cannot find path "%s" to set value', implode('/', $aPath)));
     }
     if ($bNULL) {
         unset($mPrevious[$sKey]);
     } else {
         $mCurrent = $bRef && is_array($mValue) ? $this->createInstance($mValue) : $mValue;
     }
     return $mCurrent;
 }
Beispiel #2
0
 protected function addText($mValue)
 {
     if (is_string($mValue)) {
         $sValue = $mValue;
     } else {
         if ($mValue instanceof core\stringable) {
             $sValue = $mValue->asString();
         } else {
             $this->launchException("Unknow value type : " . \Sylma::show($mValue));
         }
     }
     return array('script' => array('@type' => 'text/javascript', $sValue));
 }
Beispiel #3
0
 public function setCalled($called)
 {
     if ($called instanceof common\_var) {
         $instance = $called->getInstance();
     } else {
         $instance = $called;
         $called = $this->getControler()->addVar($called);
     }
     if (!$instance instanceof _Closure) {
         $this->getControler()->throwException(sprintf('Cannot call %s', \Sylma::show($called)));
     }
     $this->called = $called;
 }
Beispiel #4
0
 protected function normalizeObject($val, $iMode)
 {
     $mResult = null;
     if (self::DEBUG_NORMALIZE_RECURSION) {
         foreach (self::$aNormalizedObjects as $obj) {
             if ($obj === $val) {
                 \Sylma::throwException("Recursion when normalizing with object : " . \Sylma::show($val));
             }
         }
     }
     if ($val instanceof core\argumentable) {
         if ($arg = $val->asArgument()) {
             $mResult = $this->normalizeArgument($arg, $iMode);
         }
     } else {
         if ($val instanceof core\argument) {
             if ($iMode & self::NORMALIZE_ARGUMENT) {
                 $mResult = $this->normalizeArgument($val, $iMode);
             } else {
                 $mResult = $val;
             }
         } else {
             if ($val instanceof core\stringable) {
                 $mResult = $val->asString();
             } else {
                 if ($val instanceof core\arrayable) {
                     $mResult = $val->asArray();
                 } else {
                     $mResult = $this->normalizeObjectUnknown($val, $iMode);
                 }
             }
         }
     }
     if (self::DEBUG_NORMALIZE_RECURSION) {
         self::$aNormalizedObjects[] = $val;
     }
     return $mResult;
 }
Beispiel #5
0
 protected function loadVariables($bHTML = true)
 {
     $sResult = '';
     if ($this->getVariables()) {
         $sResult .= '<ul class="sylma-variables" tabindex="1">';
         $sResult .= '<h3>Variables</h3>';
         foreach ($this->getVariables() as $sName => $mVar) {
             $sResult .= '<li><strong>' . $sName . '</strong> :' . \Sylma::show($mVar, !$bHTML) . '</li>';
         }
         $sResult .= '</ul>';
     }
     return $sResult;
 }