/** * 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; } CmsException::mask($obj, 200); $parsedData = SectionParser::parse($obj->content); CmsException::unmask(); $obj->settings = $parsedData['settings']; $obj->code = $parsedData['code']; $obj->markup = $parsedData['markup']; $obj->parseComponentSettings(); $obj->parseSettings(); return $obj; }
/** * Loads the object from a file. * This method is used in the CMS back-end. It doesn't use any caching. * @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 mixed Returns a CMS object instance or null if the object wasn't found. */ public static function load($theme, $fileName) { if (!strlen(File::extension($fileName))) { $fileName .= '.yaml'; } if (($obj = parent::load($theme, $fileName)) === null) { return null; } $parsedData = Yaml::parse($obj->content); if (!array_key_exists('name', $parsedData)) { throw new SystemException(sprintf('The content of the %s file is invalid: the name element is not found.', $fileName)); } $obj->name = $parsedData['name']; if (isset($parsedData['items'])) { $obj->items = MenuItem::initFromArray($parsedData['items']); } return $obj; }