Beispiel #1
0
 protected function createView($action = 'view')
 {
     $controller = \Staq\Util::getStackSubQuery($this);
     $view = (new \Stack\View())->byName($action, $controller);
     $view['controller'] = $controller;
     $view['controllerAction'] = $action;
     return $view;
 }
Beispiel #2
0
 public function __construct()
 {
     $this->settings = (new \Stack\Setting())->parse($this);
     $this->name = strtolower(\Staq\Util::getStackSubQuery($this, '_'));
     $this->table = $this->settings->get('database.table', $this->name);
     $this->idField = $this->settings['database.idField'];
     $this->fields = $this->settings->getAsArray('database.fields');
 }
Beispiel #3
0
 protected function newEntity()
 {
     $class = 'Stack\\Entity';
     $subQuery = \Staq\Util::getStackSubQuery($this);
     if ($subQuery) {
         $class .= '\\' . $subQuery;
     }
     return new $class();
 }
Beispiel #4
0
 public function __construct()
 {
     $settings = (new \Stack\Setting())->parse($this);
     $this->name = \Staq\Util::getStackSubQuery($this, '_');
     $this->folder = '/data/' . $this->name;
     if (isset($settings['idField'])) {
         $this->idField = $settings['idField'];
     }
 }
Beispiel #5
0
 public function getRoute($controller, $action)
 {
     if (is_object($controller)) {
         $controller = \Staq\Util::getStackSubQuery($controller);
     }
     if (isset($this->routes[$controller][$action])) {
         return $this->routes[$controller][$action];
     }
 }
Beispiel #6
0
 public static function findTemplate($stack, $action = NULL)
 {
     $template = strtolower(\Staq\Util::getStackSubQuery($stack, '/')) . '.twig';
     $template = str_replace('_', '/', $template);
     if (!empty($action)) {
         $template = $action . '/' . $template;
     }
     $folder = strtolower(\Staq\Util::getStackType($stack));
     while (TRUE) {
         if (\Staq::App()->getFilePath('template/' . $folder . '/' . $template)) {
             break;
         }
         if (\UString::has($template, '/')) {
             $template = \UString::substrBeforeLast($template, '/') . '.twig';
         } else {
             $template = 'index.twig';
             break;
         }
     }
     return $folder . '/' . $template;
 }
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 getModel()
 {
     $modelClass = 'Stack\\Model\\' . \Staq\Util::getStackSubQuery($this);
     return new $modelClass();
 }
Beispiel #9
0
 public static function getStackSubQueryText($stack)
 {
     $subQuery = \Staq\Util::getStackSubQuery($stack);
     return str_replace(['\\', '_'], ' ', $subQuery);
 }