Example #1
0
 /**
  * Initializes the Spire framework.
  *
  * @return void
  */
 public static function initialize()
 {
     // Start the system.
     Spire::start();
     // Load routes.
     static::routes();
     // Find the current route.
     $route = Repository::retrieve(Request::method(), Uri::segmentString());
     // If no route was found, show a 404.
     if (empty($route)) {
         die('404');
     }
     // Instantiate the module.
     static::$module = $module = new Module($route);
     // Run the module.
     $response = $module->run();
     // Run the response.
     if (is_object($response) && method_exists($response, 'respond')) {
         $response->respond();
     }
     // Do we have a layout to process?
     $layout = $module->instance()->layout;
     // Process layout.
     if ($layout !== '') {
         echo Layout::get($layout);
     }
     // Close Spire.
     Spire::close();
 }
Example #2
0
 public function __construct(Cache $Cache, \PDO $DB, Translate $Translate, array $config = [])
 {
     $this->Cache = $Cache;
     $this->DB = $DB;
     $this->Translate = $Translate;
     $this->mergeConfig($config);
     if (empty(self::$module)) {
         static::$module = $this->queryModule();
         static::$routing = $this->queryRouting();
     }
 }
Example #3
0
 /**
  * Submodules constructor.
  * @param string|null $module
  * @param bool $reset
  */
 function __construct($module = NULL, $reset = FALSE)
 {
     if (static::$module || !$module) {
         return;
     }
     static::$module = $module;
     $storage = PhpStorageFactory::get($module);
     if ($reset || $this->isReset() || !$storage->exists($module)) {
         $this->scanImplementations();
         $this->sortImplementations();
         $this->generateCode();
         $storage->deleteAll();
         $storage->save($module, implode("\n\n", $this->code) . "\n");
         Drupal::configFactory()->getEditable(static::$module . '.settings')->delete();
     }
     require_once $storage->getFullPath($module);
 }
Example #4
0
 /**
  * Used in the 'behind the scenes' logic during a frontend request, this checks whether
  * there is a controller associated with a particular template
  * 
  * @param string $template Path to the template, relative to the root of the views directory
  * @return boolean
  */
 public static function hasController($template)
 {
     static::$path = strpos($template, '.') === false ? $template : substr($template, 0, -strlen(strrchr($template, '.')));
     // determine the viewmodel namespace and classname
     if (empty(static::$module)) {
         static::$module = \Request::active() ? ucfirst(\Request::active()->module) : '';
     }
     // Strip the first part of the path off for module templates
     if (!empty(static::$module) && strpos(static::$path, static::$module) === 0) {
         static::$path = str_replace(static::$module . '/', '', static::$path);
     }
     $controller_class = ucfirst(static::$module) . '\\Controller_' . \Inflector::words_to_upper(ucfirst(str_replace(array('/', DS), '_', static::$path)));
     return class_exists($controller_class);
 }
Example #5
0
 /**
  * Load view with module prefix
  * @param string $module
  * @param function $callback
  */
 public static function viewModule($module, $callback)
 {
     static::$module = $module;
     $callback($module);
     static::$module = null;
 }
Example #6
0
File: Model.php Project: hejxing/jt
 /**
  * 类加载后自动执行的方法
  *
  * @param string $className 当前类名
  */
 public static function __init($className)
 {
     //解析表结构和属性
     if ($className !== __CLASS__) {
         self::parseColumns();
         static::$module = substr($className, 0, strpos($className, '\\model\\'));
     }
 }