Example #1
0
 function __invoke($error, $method, $path, \cms\Sphido $cms)
 {
     trigger(MissingPage::class . '_before', $error, $method, $path, $cms);
     if ($cms->page = Page::fromPath(\dir\content() . '/404', (array) \app\config()->meta)) {
         return $cms->render();
     }
     trigger(MissingPage::class . '_default', $error, $method, $path, $cms);
 }
Example #2
0
 /**
  * @param $method
  * @param $path
  * @param $cms
  * @return mixed
  */
 function __invoke($method, $path, $cms)
 {
     $this->cms = $cms = $this;
     // inclide prepend PHP file first
     is_file($php = \dir\content($path . '/index.php')) ? include_once $php : null || is_file($php = \dir\content($path . '.php')) ? include_once $php : null;
     // search page (html, md, latte, phtml)
     $this->page = Page::fromPath(\dir\content() . '/' . $path, (array) config()->meta);
     // include functions.php from $path and working directory
     is_file($php = \dir\content($path . '/function.php')) ? include_once $php : null;
     is_file(getcwd() . '/functions.php') ? include_once getcwd() . '/functions.php' : null;
     if ($this->page) {
         echo ensure('render.page', [$this, 'render'], $this);
         // render page
     } else {
         error(404, $method, $path, $this);
         // trigger router error
     }
 }