/** * Load configuration files. * * @param Registry $config The config registry object. * * @throws \RuntimeException * * @return void */ public static function loadConfiguration(Registry $config) { $config->loadFile($file = WINDWALKER_ETC . '/config.yml', 'yaml'); $secret = WINDWALKER_ETC . '/secret.yml'; if (is_file($secret)) { $config->loadFile($secret, 'yaml'); } }
/** * loadConfiguration * * @param \Windwalker\Registry\Registry $config * * @return void */ protected function loadConfiguration($config) { $file = $this->get('project.path.root') . '/.vaseman/config.yml'; if (is_file($file)) { $config->loadFile($file, 'yaml'); } }
/** * loadConfiguration * * @param Registry $config * * @throws \RuntimeException * @return void */ public static function loadConfiguration(Registry $config) { $file = WINDWALKER_ETC . '/config.yml'; if (!is_file($file)) { exit('Please copy config.dist.yml to config.yml'); } $config->loadFile($file, 'yaml'); }
/** * Get routing config. * * @param string $option The component option name. * @param string $type The routing file type. * * @return mixed */ public static function getRouting($option, $type = self::TYPE_YAML) { if (self::$routing) { return self::$routing; } $path = PathHelper::getSite($option); $fileType = $type == static::TYPE_YAML ? 'yml' : $type; $data = new Registry(); $data->loadFile($path . '/routing.' . $fileType, $type); return self::$routing = $data->toArray(); }
/** * onBeforeRenderFiles * * @param Event $event * * @return void */ public function onBeforeRenderFiles(Event $event) { $this->data = array(); $files = new \DirectoryIterator(__DIR__ . '/../../resources'); $resources = new PriorityQueue(); $menus = new PriorityQueue(); /** @var \SplFileInfo $file */ foreach ($files as $file) { if ($file->isDir()) { continue; } $data = new Registry(); $data->loadFile($file->getPathname(), 'yaml'); $resName = $file->getBasename('.yml'); list($priority, $resName) = explode('-', $resName, 2); $data['alias'] = $resName; $resources->insert($data->toArray(), PHP_INT_MAX - $priority); $menus->insert(array('title' => $data['title'], 'alias' => $resName), PHP_INT_MAX - $priority); } // Store in cache $this->data['menus'] = $menus->toArray(); foreach ($resources as $data) { $this->data['resources'][$data['alias']] = $data; } // Auto create pages $categoryFolder = new \SplFileInfo(__DIR__ . '/../../entries/type'); if (is_dir($categoryFolder->getPathname())) { Folder::delete($categoryFolder->getPathname()); } Folder::create($categoryFolder->getPathname()); foreach ($this->data['resources'] as $catName => &$category) { File::copy(__DIR__ . '/../../layouts/tmpl/category.twig', __DIR__ . '/../../entries/type/' . $catName . '.twig'); // Auto create items page $itemFolder = new \SplFileInfo(__DIR__ . '/../../entries/type/' . $catName); if (is_dir($itemFolder->getPathname())) { Folder::delete($itemFolder->getPathname()); } Folder::create($itemFolder->getPathname()); foreach ($category['data'] as $itemAlias => &$item) { File::copy(__DIR__ . '/../../layouts/tmpl/item.twig', __DIR__ . '/../../entries/type/' . $catName . '/' . $itemAlias . '.twig'); $item['alias'] = $itemAlias; } } }
/** * Load the contents of a file into the registry * * @param string $file Path to file to load * @param string $format Format of the file [optional: defaults to JSON] * @param array $options Options used by the formatter * * @return Registry Return this object to support chaining. * * @since 1.0 */ public function loadFile($file, $format = 'JSON', $options = array()) { $this->registry->loadFile($file, $format, $options); return $this; }
/** * Load config. * * @return Registry Config registry object. */ public function loadConfig() { $file = WINDWALKER . '/config.json'; if (!is_file($file)) { \JFile::copy(WINDWALKER . '/config.dist.json', $file); } $config = new Registry(); return $config->loadFile($file, 'json'); }