Beispiel #1
0
 public function parse($mixed)
 {
     if (\Staq\Util::isStack($mixed)) {
         return $this->parseFromStack($mixed);
     }
     return $this->parseFromString($mixed);
 }
Beispiel #2
0
 protected function render($view)
 {
     $view = parent::render($view);
     if (!\Staq\Util::isStack($view, 'Stack\\View')) {
         $page = new \Stack\View();
         $page['content'] = $view;
         $view = $page;
     }
     return $view->render();
 }
Beispiel #3
0
 public function autoload($class)
 {
     if (!static::$initialized) {
         $this->initialize();
         if ($this->classExists($class)) {
             return TRUE;
         }
     }
     if (\Staq\Util::isStack($class)) {
         $this->loadStackClass($class);
     } else {
         if (\Staq\Util::isParentStack($class)) {
             $this->loadStackParentClass($class);
         }
     }
 }
Beispiel #4
0
 public function set($model)
 {
     if (empty($model)) {
         $model = $this->getRemoteModel();
     } else {
         if (is_numeric($model)) {
             $model = $this->getRemoteModel()->entity->fetchById($model);
         } else {
             if (!\Staq\Util::isStack($model, $this->getRemoteClass())) {
                 $message = 'Input of type "' . $this->getRemoteClass() . '", but "' . gettype($model) . '" given.';
                 throw new \Stack\Exception\NotRightInput($message);
             }
         }
     }
     if ($model && $model->exists()) {
         $this->remoteModel = $model;
         $this->seed = $model->id;
     } else {
         $this->seed = NULL;
         $this->remoteModel = NULL;
     }
     return $this;
 }
Beispiel #5
0
 public function set($remoteModels)
 {
     $this->remoteModels = [];
     $this->changed = TRUE;
     \UArray::doConvertToArray($remoteModels);
     if ($this->uniqueRemote) {
         $remoteModels = array_slice($remoteModels, 0, 1);
     }
     foreach ($remoteModels as $model) {
         if (is_numeric($model)) {
             $model = $this->getRemoteModel()->entity->fetchById($model);
         } else {
             if (!\Staq\Util::isStack($model, $this->getRemoteClass())) {
                 $message = 'Input of type "' . $this->getRemoteClass() . '", but "' . gettype($model) . '" given.';
                 throw new \Stack\Exception\NotRightInput($message);
             }
         }
         if ($model && $model->exists()) {
             $this->remoteModels[] = $model;
         }
     }
     return $this;
 }
Beispiel #6
0
 public function offsetSet($index, $newVal)
 {
     $attribute = $this->getAttribute($index);
     if (\Staq\Util::isStack($attribute, 'Stack\\Attribute')) {
         $attribute->set($newVal);
     } else {
         parent::offsetSet($index, $newVal);
     }
 }
Beispiel #7
0
 public function __toString()
 {
     $str = 'Route( ' . $this->uri . ' => ';
     if (is_array($this->callable)) {
         $controller = $this->callable[0];
         if (\Staq\Util::isStack($controller)) {
             $str .= \Staq\Util::getStackSubQuery($controller);
         } else {
             $str .= \UObject::convertToClass($controller);
         }
         $str .= '::' . $this->callable[1];
     } else {
         $str .= 'anonymous';
     }
     return $str . ' )';
 }
Beispiel #8
0
 protected function preventExceptionLoop($exception)
 {
     if (\Staq\Util::isStack($exception)) {
         $name = \Staq\Util::getStackQuery($exception);
     } else {
         $name = get_class($exception);
     }
     if (in_array($name, $this->exceptionNames, TRUE)) {
         throw new \Exception('Uncatched exception "' . $exception->getMessage() . '"');
     }
     $this->exceptionNames[] = $name;
 }
Beispiel #9
0
 public static function getDeclaredStackClasses()
 {
     $stackClasses = [];
     foreach (get_declared_classes() as $class) {
         if (\Staq\Util::isStack($class)) {
             $stackClasses[] = $class;
         }
     }
     return $stackClasses;
 }