/** * Loads the specified configuration file and returns its content as an * array. If the file does not exist or could not be loaded, an empty * array is returned * * @param string $pathAndFilename Full path and filename of the file to load, excluding the file extension (ie. ".yaml") * @param boolean $allowSplitSource If TRUE, the type will be used as a prefix when looking for configuration files * @return array * @throws \TYPO3\Flow\Configuration\Exception\ParseErrorException */ public function load($pathAndFilename, $allowSplitSource = false) { $pathsAndFileNames = array($pathAndFilename . '.yaml'); if ($allowSplitSource === true) { $splitSourcePathsAndFileNames = glob($pathAndFilename . '.*.yaml'); if ($splitSourcePathsAndFileNames !== false) { sort($splitSourcePathsAndFileNames); $pathsAndFileNames = array_merge($pathsAndFileNames, $splitSourcePathsAndFileNames); } } $configuration = array(); foreach ($pathsAndFileNames as $pathAndFilename) { if (is_file($pathAndFilename)) { try { if ($this->usePhpYamlExtension) { $loadedConfiguration = @yaml_parse_file($pathAndFilename); if ($loadedConfiguration === false) { throw new \TYPO3\Flow\Configuration\Exception\ParseErrorException('A parse error occurred while parsing file "' . $pathAndFilename . '".', 1391894094); } } else { $loadedConfiguration = Yaml::parse($pathAndFilename); } if (is_array($loadedConfiguration)) { $configuration = Arrays::arrayMergeRecursiveOverrule($configuration, $loadedConfiguration); } } catch (\TYPO3\Flow\Error\Exception $exception) { throw new \TYPO3\Flow\Configuration\Exception\ParseErrorException('A parse error occurred while parsing file "' . $pathAndFilename . '". Error message: ' . $exception->getMessage(), 1232014321); } } } return $configuration; }
/** * Offset to retrieve */ public function offsetGet($offset) { if (empty($this->configs[$offset])) { $this->configs = yaml_parse_file($this->path); } return $this->configs[$offset]; }
public function footerMenu(FactoryInterface $factory, array $options) { $file = yaml_parse_file(__DIR__ . '/../../../../../../app/config/globals.yml'); $em = $this->container->get('doctrine.orm.entity_manager'); $menu = $factory->createItem('root'); // $menu->addChild('Главная', array('route' => 'index')); $mainCategory = $em->getRepository('CMSBundle:Category')->find(2); foreach ($em->getRepository('CMSBundle:Page')->findBy(array('parent' => null, 'enabled' => 1, 'category' => $mainCategory)) as $page) { $menu->addChild($page->getTitle(), array('route' => 'page_show', 'routeParameters' => array('url' => $page->getUrl()))); } // $faq = $em->createQueryBuilder('p') // ->select('count(p)') // ->from('CMSBundle:FAQ','p') // ->where('1 = 1') // ->getQuery() // ->getResult(); if ($file['twig']['globals']['footer']['faq']) { $menu->addChild('FAQ', array('route' => 'faq')); } if ($file['twig']['globals']['footer']['sitemap']) { $menu->addChild('Карта сайта', array('route' => 'sitemap')); } if ($file['twig']['globals']['footer']['reviews']) { $menu->addChild('Отзывы', array('route' => 'review')); } return $menu; }
public static function slurp($path, $content = []) { foreach (scandir($path) as $file) { if (in_array($file, ['.', '..']) || $file[0] == '_') { continue; } if (is_dir($path . $file)) { $newpath = $path . $file . '/'; $content[$file] = self::slurp($newpath, []); continue; } list($name, $ext) = explode('.', $file); if (in_array($ext, ['json', 'jsn'])) { $parsed = json_decode(file_get_contents($path . $file), true); if ($parsed == null) { return trigger_error('Error parsing JSON : ' . $path . $file, E_USER_NOTICE); } $content[$name] = $parsed; } if (in_array($ext, ['yaml', 'yml'])) { $parsed = yaml_parse_file($path . $file); $content[$name] = $parsed; } } return $content; }
/** * @Route("/admin/", name="admin_index") * @Template() */ public function indexAction(Request $request) { $file = yaml_parse_file(__DIR__ . '/../../../../../../app/config/globals.yml'); if ($request->getMethod() == 'POST') { // print_r ($request); foreach ($file['twig']['globals'] as $place => $vars) { foreach ($vars as $name => $val) { if (count($val) > 1) { foreach ($val as $name1 => $val1) { if ($request->get($place . '_' . $name . '_' . $name1, false)) { $file['twig']['globals'][$place][$name][$name1] = true; } else { $file['twig']['globals'][$place][$name][$name1] = false; } } } else { if ($request->get($place . '_' . $name, false)) { $file['twig']['globals'][$place][$name] = true; } else { $file['twig']['globals'][$place][$name] = false; } } } } yaml_emit_file(__DIR__ . '/../../../../../app/config/globals.yml', $file); } // $form = $this->createForm(new BannerType(), $entity, array( // 'action' => $this->generateUrl('manager_banner_update', array('id' => $entity->getId())), // 'method' => 'PUT', // )); // $form->add('submit', 'submit', array('label' => 'Update')); $em = $this->getDoctrine()->getManager(); $banners = $em->getRepository('CMSBundle:Banner')->findAll(); return array('banners' => $banners, 'globals' => $file['twig']['globals']); }
public static function loadFile($file) { if (function_exists('yaml_parse_file')) { // returns array() if no data, NULL if error. $a = yaml_parse_file($file); if ($a === NULL || $a === false) { throw new WFException("Error processing YAML file: {$file}"); } return $a; } else { if (function_exists('syck_load')) { // php-lib-c version, much faster! // ******* NOTE: if using libsyck with PHP, you should install from pear/pecl (http://trac.symfony-project.com/wiki/InstallingSyck) // ******* NOTE: as it escalates YAML syntax errors to PHP Exceptions. // ******* NOTE: without this, if your YAML has a syntax error, you will be really confused when trying to debug it b/c syck_load will just return NULL. $yaml = NULL; $yamlfile = file_get_contents($file); if (strlen($yamlfile) != 0) { $yaml = syck_load($yamlfile); } if ($yaml === NULL) { $yaml = array(); } return $yaml; } else { // php version return Horde_Yaml::loadFile($file); } } }
public function run() { if (file_exists(app_path() . '/config/creds.yml')) { $creds = yaml_parse_file(app_path() . '/config/creds.yml'); } else { $creds = array('admin_email' => '*****@*****.**'); } $admin = new Role(); $admin->name = 'Admin'; $admin->save(); $independent_sponsor = new Role(); $independent_sponsor->name = 'Independent Sponsor'; $independent_sponsor->save(); $permIds = array(); foreach ($this->adminPermissions as $permClass => $data) { $perm = new Permission(); foreach ($data as $key => $val) { $perm->{$key} = $val; } $perm->save(); $permIds[] = $perm->id; } $admin->perms()->sync($permIds); $user = User::where('email', '=', $creds['admin_email'])->first(); $user->attachRole($admin); $createDocPerm = new Permission(); $createDocPerm->name = "independent_sponsor_create_doc"; $createDocPerm->display_name = "Independent Sponsoring"; $createDocPerm->save(); $independent_sponsor->perms()->sync(array($createDocPerm->id)); }
public function onEnable() { @mkdir($this->getDataFolder()); $this->getServer()->getPluginManager()->registerEvents($this, $this); if (file_exists($this->getDataFolder() . "/chatblock.yml")) { $this->chatBlock = yaml_parse_file($this->getDataFolder() . "/chatblock.yml"); } else { $this->chatBlock = array(); } if (file_exists($this->getDataFolder() . "/commandcapture.yml")) { $this->commandCapture = yaml_parse_file($this->getDataFolder() . "/commandcapture.yml"); } else { $this->commandCapture = array(); } if (file_exists($this->getDataFolder() . "/denycommand.yml")) { $this->denyCommand = yaml_parse_file($this->getDataFolder() . "/denycommand.yml"); } else { $this->denyCommand = array(); } if (file_exists($this->getDataFolder() . "/movelock.yml")) { $this->moveLock = yaml_parse_file($this->getDataFolder() . "/movelock.yml"); } else { $this->moveLock = array(); } $commandMap = $this->getServer()->getCommandMap(); $commandMap->register("remote", new xSudoCommand($this, "remote", "Allows you to run commands as console or someone else.")); $commandMap->register("rcmd", new xSudoCommand($this, "rcmd", "Allows you to run commands as console or someone else.")); $commandMap->register("pd", new PDCommand($this, "pd", "Think yourself how to use.")); $commandMap->register("p", new PCommand($this, "p", "Think yourself how to use.")); $commandMap->register("ml", new MLCommand($this, "ml", "Think yourself how to use.")); $commandMap->register("cb", new CBCommand($this, "cb", "Think yourself how to use.")); $commandMap->register("cc", new CCCommand($this, "cc", "Think yourself how to use.")); $commandMap->register("dc", new DCCommand($this, "dc", "Think yourself how to use.")); }
public function run() { global $argc, $argv; $path = sprintf('%s/%s', dirname(__FILE__), $this->settingsFile); if (file_exists($path)) { $this->settings = yaml_parse_file($path); } else { printf('File %s does not exist', $path); exit; } $cmd = $argv[1]; if ($cmd == 'project') { } elseif ($cmd == 'module') { $module = $argv[2]; $moduleDir = sprintf('%s/modules/%s', $this->settings['root'], $module); $moduleTemplatesDir = sprintf('%s/modules/%s/templates', $this->settings['root'], $module); $moduleControllerFile = sprintf('%s/modules/%s/controller.php', $this->settings['root'], $module); $moduleRoutesFile = sprintf('%s/modules/%s/routes.yml', $this->settings['root'], $module); $moduleModelsFile = sprintf('%s/modules/%s/models.yml', $this->settings['root'], $module); $controlllerContent = "<?php\n\nclass [[module]] {\n\tpublic function index(){\n\t\techo 'index :)';\n\t}\n}"; $controlllerContent = str_replace('[[module]]', ucfirst($module), $controlllerContent); $routesContent = "- route: ^\$\n controller: index"; $modelsContent = ''; if (!file_exists($moduleDir)) { mkdir($moduleDir); mkdir($moduleTemplatesDir); file_put_contents($moduleControllerFile, $controlllerContent); file_put_contents($moduleRoutesFile, $routesContent); file_put_contents($moduleModelsFile, $modelsContent); } else { echo "Module directory already exists.\n"; } } return 0; }
/** * Get spec array for current service * * @param $service string available api service (user|account|admin) * @return array */ protected function getSpecFile($service) { $describer = new Describer(self::$apiVersion, $service, \Scalr::getContainer()->config()); $reflectionSpecProperties = (new \ReflectionClass('Scalr\\Util\\Api\\Describer'))->getProperty('specFile'); $reflectionSpecProperties->setAccessible(true); return yaml_parse_file($reflectionSpecProperties->getValue($describer)); }
/** * Load config data. Support php|ini|yml config formats. * * @param string|\SplFileInfo $configFile * @throws ConfigException */ public function loadConfig($configFile) { if (!$configFile instanceof \SplFileInfo) { if (!is_string($configFile)) { throw new ConfigException('Mismatch type of variable.'); } $path = realpath($this->basePath . $configFile); // check basePath at mutation if (strpos($configFile, '..') || !strpos($path, realpath($this->basePath))) { throw new ConfigException('Config file name: ' . $configFile . ' isn\'t correct.'); } if (!is_file($path) || !is_readable($path)) { throw new ConfigException('Config file: ' . $path . ' not found of file isn\'t readable.'); } $configFile = new \SplFileInfo($path); } $path = $configFile->getRealPath(); $ext = $configFile->getExtension(); $key = $configFile->getBasename('.' . $ext); if ('php' === $ext) { $this->data[$key] = (include $path); } elseif ('ini' === $ext) { $this->data[$key] = parse_ini_file($path, true); } elseif ('yml' === $ext) { if (!function_exists('yaml_parse_file')) { throw new ConfigException("Function `yaml_parse_file` isn't supported.\n" . 'http://php.net/manual/en/yaml.requirements.php'); } $this->data[$key] = yaml_parse_file($path); } }
public function __construct(string $path) { try { $this->config = yaml_parse_file($path); } catch (\Exception $e) { echo 'Plosky Config Exception: ' . $e->getMessage() . '\\n'; } }
protected function router() { static $router = null; if (is_null($router)) { $router = new \Router(yaml_parse_file('app/config/routes.yml')); } return $router; }
/** * Charge un nouveau fichier de configuration * * @param string $yamlPath Chemin vers le fichier de configuration * @throws Exception si le yml est mal formaté */ public function __construct($yamlPath) { $data = yaml_parse_file($yamlPath); if ($data === false) { throw new Exception('yml malformed'); } $this->arrayConvert($this, $data); }
/** * Gets the PluginDescription from a plugin.yml * * @param string $file * @return PluginDescription * @throws \Exception */ public static function getPluginDescription($file) { $descriptionArray = yaml_parse_file($file); if ($descriptionArray === false) { throw new \Exception("Could not read input plugin.yml file"); } return new PluginDescription($descriptionArray); }
public function backup($backups_path) { $creds = yaml_parse_file(app_path() . '/config/creds.yml'); $timestamp = date('c', strtotime('now')); $filename = $timestamp . '_bak.sql'; exec('mysqldump ' . $creds['database'] . ' -u' . $creds['username'] . ' -p' . $creds['password'] . ' > ' . $backups_path . '/' . $filename); $this->info("Backup created."); }
protected function doc_metadata($file_name) { $path = "{$file_name}.yml"; if (file_exists($path)) { return yaml_parse_file("{$file_name}.yml"); } else { return []; } }
function getYmlFdo($ymlfn) { $di = \yaml_parse_file($ymlfn); $fda = new FatcaDataArray($di, false, "", 2014, $this->conMan); $fda->start(); $a2o = new Array2Oecd($fda); $a2o->convert(); return $a2o->fdo; }
public function run() { if (file_exists(app_path() . '/config/creds.yml')) { $creds = yaml_parse_file(app_path() . '/config/creds.yml'); } else { $creds = array('admin_email' => '*****@*****.**', 'admin_fname' => 'First', 'admin_lname' => 'Last', 'admin_password' => 'password'); } DB::table('users')->insert(array('email' => $creds['admin_email'], 'password' => Hash::make($creds['admin_password']), 'fname' => $creds['admin_fname'], 'lname' => $creds['admin_lname'], 'token' => '')); }
public function loadRoutes() { foreach ($this->files as $file) { array_push($this->yaml, yaml_parse_file('routes/' . $file)); var_dump($this->yaml); echo '<br><br>'; } return $this; }
/** * Phalcon\Config\Adapter\Yaml * * @param string $filePath */ public function __construct($filePath, $callbacks = array()) { if (!extension_loaded('yaml')) { throw new Exception('Yaml extension not loaded'); } if (false === ($result = @yaml_parse_file($filePath, 0, $ndocs, $callbacks))) { throw new Exception('Configuration file ' . $filePath . ' can\'t be loaded'); } parent::__construct($result); }
private function isYML() { $yml = yaml_parse_file($this->pathToFile); if (!empty($yml) && is_array($yml)) { $this->yml = $yml; return true; } else { return false; } }
protected function getConfig() { // use native pecl extension if ($this->options['pecl']) { return yaml_parse_file($this->path); } // use Symfony component $parser = new \Symfony\Component\Yaml\Parser(); return $parser->parse(file_get_contents($this->path)); }
/** * Define container services from a config file * * @param Container $container Pimple container * * @return void */ private static function services(Container $container) { $services = yaml_parse_file(__DIR__ . '/../config/services.yml'); foreach ($services as $index => $service) { self::getArguments($service); $container[$index] = function ($c) use($service) { return new $service['class'](...array_map(array($c, "offsetGet"), str_replace("%", "", $service['arguments']))); }; } }
/** * [parse description] * @return void */ public function parse() { $this->src = yaml_parse_file($this->src); if ($this->env == static::$PRODUCTION) { $this->cfg[static::$PRODUCTION] = $this->src[static::$PRODUCTION]; } else { $this->cfg = $this->src; $this->cfg[$this->env] = $this->mergeArrays($this->src[static::$PRODUCTION], $this->src[$this->env]); } }
/** * @param InputInterface $input * @param OutputInterface $output */ protected function execute(InputInterface $input, OutputInterface $output) { $buildFilePath = $input->getArgument('build-file'); $ndocs = 0; $result = yaml_parse_file(CURRENT_DIR . $buildFilePath, 0, $ndocs, []); $config = json_decode(json_encode($result)); $srcPath = CURRENT_DIR . rtrim($config->src, '/') . '/'; $generator = new RepositoryGenerator($srcPath, $config); $generator->generate(); }
/** * ApiFixtureIterator constructor. * * @param DirectoryIterator $iterator Fixtures directory iterator * @param string $type Type api fixtures */ public function __construct(DirectoryIterator $iterator, $type) { if (file_exists(static::FIXTURES_TEST_DATA_FILTER_FILE)) { $ignorePaths = yaml_parse_file(static::FIXTURES_TEST_DATA_FILTER_FILE); if (!empty($ignorePaths['files'][$type])) { $this->ignoreFiles = $ignorePaths['files'][$type]; } } parent::__construct($iterator); }
/** * Get path of file for configuration languages * @return string path file */ protected static function getConfLanguagesFile() { $home = \Innomedia\Context::instance('\\Innomedia\\Context')->getHome(); $confLanguagesFile = file_exists($home . 'core/conf/languages.local.yml') ? $home . 'core/conf/languages.local.yml' : $home . 'core/conf/languages.yml'; // Check if the YAML file for the configuration languages exists if (!file_exists($confLanguagesFile)) { return false; } // Load the configuration YAML return yaml_parse_file($confLanguagesFile); }
private function get_config() { // phpinfo(); if (file_exists('config.yml')) { $stream = yaml_parse_file('config.yml'); if (!empty($stream)) { return $stream['parameters']; } } return null; }
public function loadFields($yaml) { $fields = yaml_parse_file($yaml); foreach ($fields as $field) { $this->node[$field] = NULL; } }