/** * Loads the object from a file. * @param \Cms\Classes\Theme $theme Specifies the theme the object belongs to. * @param string $fileName Specifies the file name, with the extension. * The file name can contain only alphanumeric symbols, dashes and dots. * @return boolean Returns true if the object was successfully loaded. Otherwise returns false. */ public static function load($theme, $fileName) { if (($obj = parent::load($theme, $fileName)) === null) { return null; } $parsedData = CmsException::capture($obj, 200, function () use($obj) { return SectionParser::parse($obj->content); }); $obj->settings = $parsedData['settings']; $obj->code = $parsedData['code']; $obj->markup = $parsedData['markup']; $obj->parseComponentSettings(); $obj->parseSettings(); return $obj; }
/** * Executes the page life cycle. * Creates an object from the PHP sections of the page and * it's layout, then executes their life cycle functions. */ protected function execPageCycle() { /* * Extensibility */ if ($event = Event::fire('cms.page.start', [$this], true)) { return $event; } if ($event = $this->fireEvent('page.start', [$this], true)) { return $event; } /* * Run layout functions */ if ($this->layoutObj) { $response = CmsException::capture($this->layout, 300, function () { return ($result = $this->layoutObj->onStart()) || ($result = $this->layout->runComponents()) || ($result = $this->layoutObj->onBeforePageStart()) ? $result : null; }); if ($response) { return $response; } } /* * Run page functions */ $response = CmsException::capture($this->page, 300, function () { return ($result = $this->pageObj->onStart()) || ($result = $this->page->runComponents()) || ($result = $this->pageObj->onEnd()) ? $result : null; }); if ($response) { return $response; } /* * Run remaining layout functions */ if ($this->layoutObj) { $response = CmsException::capture($this->layout, 300, function () { return ($result = $this->layoutObj->onEnd()) ? $result : null; }); } /* * Extensibility */ if ($event = Event::fire('cms.page.end', [$this], true)) { return $event; } if ($event = $this->fireEvent('page.end', [$this], true)) { return $event; } return $response; }