当前位置: 首页>>代码示例>>PHP>>正文


PHP Config\FileLocator类代码示例

本文整理汇总了PHP中Symfony\Component\Config\FileLocator的典型用法代码示例。如果您正苦于以下问题:PHP FileLocator类的具体用法?PHP FileLocator怎么用?PHP FileLocator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FileLocator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 public function setUp()
 {
     $kernel = static::createKernel();
     $kernel->boot();
     if ($kernel->getContainer()->getParameter('database_driver') == 'pdo_sqlite') {
         $this->markTestSkipped("The SQLite does not support joins.");
     }
     $this->em = $kernel->getContainer()->get('knp_bundles.entity_manager');
     $fileLocator = new FileLocator(__DIR__ . '/fixtures/');
     $path = $fileLocator->locate('trending-bundles.yml');
     $data = Yaml::parse($path);
     $developer = new Developer();
     $developer->setName('someName');
     $developer->setScore(0);
     $this->em->persist($developer);
     foreach ($data['bundles'] as $bundleName => $bundleData) {
         $bundle = new Bundle('vendor/' . $bundleName);
         $bundle->setDescription('some description');
         $bundle->setScore(100);
         $bundle->setOwner($developer);
         foreach ($bundleData['scores'] as $scoreData) {
             $bundle->setDescription(md5(time() . serialize($scoreData)));
             $score = new Score();
             $score->setDate(new \DateTime($scoreData['date']));
             $score->setBundle($bundle);
             $score->setValue($scoreData['value']);
             $this->em->persist($score);
         }
         $this->em->persist($bundle);
     }
     $this->em->flush();
 }
开发者ID:KnpLabs,项目名称:KnpBundles,代码行数:32,代码来源:KbUpdateTrendsCommandTest.php

示例2: loadConfig

 /**
  * Loads the config
  */
 private function loadConfig()
 {
     $directories = [BASE_DIR . '/config', '/etc/blackhole-bot/'];
     $locator = new FileLocator($directories);
     $loader = new YamlConfigLoader($locator);
     $this->container->set('config', (new Processor())->processConfiguration($this, $loader->load($locator->locate('blackhole.yml'))));
 }
开发者ID:jlkaufman,项目名称:blackhole-bot,代码行数:10,代码来源:Configuration.php

示例3: collectDatabasesStrategies

 /**
  * @return DatabaseBackupStrategyModel[]
  */
 public function collectDatabasesStrategies()
 {
     $fileLocator = new FileLocator(__DIR__ . '/../../../app/config');
     try {
         $fileStrategies = $fileLocator->locate('strategies.yml');
     } catch (InvalidArgumentException $ex) {
         /* No strategies file detected? No strategies then. :=) */
         return [];
     }
     $strategies = file_get_contents($fileStrategies);
     $config = Yaml::parse($strategies);
     $config = $config['easy_backups'];
     $processor = new Processor();
     $configuration = new DatabaseStrategyConfiguration();
     $validatedConfig = $processor->processConfiguration($configuration, [$config]);
     $strategies = [];
     if (isset($validatedConfig['strategies'])) {
         foreach ($validatedConfig['strategies'] as $strategyConfig) {
             $strategy = new DatabaseBackupStrategyModel($strategyConfig['identifier'], $strategyConfig['compressor_strategy'], $strategyConfig['saver_strategy'], $strategyConfig['dump_settings']['type'], new DatabaseSettings($strategyConfig['dump_settings']['options']['host'], $strategyConfig['dump_settings']['options']['user'], $strategyConfig['dump_settings']['options']['pass'], $strategyConfig['dump_settings']['options']['name'], $strategyConfig['dump_settings']['options']['port'], $strategyConfig['dump_settings']['options']['ignore_tables'], $strategyConfig['dump_settings']['options']['one_dump_per_table']));
             $strategy->setDescription($strategyConfig['description']);
             $strategies[] = $strategy;
         }
     }
     return $strategies;
 }
开发者ID:Viscaweb,项目名称:EasyBackups,代码行数:28,代码来源:BackupStrategiesCollector.php

示例4: getParameters

 /**
  * @return array
  */
 private static function getParameters()
 {
     $locator = new FileLocator(__DIR__ . '/../../../../');
     $configLoc = $locator->locate('config.yml');
     $config = Yaml::parse($configLoc);
     return $config['parameters'];
 }
开发者ID:immersivelabs,项目名称:cara-sapi-development-kit,代码行数:10,代码来源:APIServiceFactory.php

示例5: initialize

 /**
  * Initialize the service container (and extensions), and load the config file
  *
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  *
  * @throws \Exception if user-provided configuration file causes an error
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     $root = $input->getArgument('root');
     // Setup container
     $containerBuilder = new ContainerBuilder();
     $extension = new BrancherExtension();
     $containerBuilder->registerExtension($extension);
     $containerBuilder->addCompilerPass(new ExtensionCompilerPass());
     $containerBuilder->addCompilerPass(new RegisterListenersPass('event_dispatcher', 'brancher.event_listener', 'brancher.event_subscriber'));
     // Try and load config file
     $locator = new FileLocator([getcwd(), $input->getArgument('root'), __DIR__ . '/../']);
     /** @var \Symfony\Component\DependencyInjection\Loader\FileLoader $loader */
     $loader = new DelegatingLoader(new LoaderResolver([new YamlFileLoader($containerBuilder, $locator), new XmlFileLoader($containerBuilder, $locator), new PhpFileLoader($containerBuilder, $locator), new IniFileLoader($containerBuilder, $locator)]));
     $config = null;
     try {
         $config = $locator->locate($input->getOption('config'));
         $loader->load($input->getOption('config'));
     } catch (\Exception $ex) {
         // Only rethrow if the issue was with the user-provided value
         if ($input->getOption('config') !== '_config.yml') {
             throw $ex;
         }
     }
     // Add in final config from command line options
     $containerBuilder->setParameter('castlepointanime.brancher.build.config', $config);
     $containerBuilder->loadFromExtension($extension->getAlias(), ['build' => array_filter(['config' => dirname($config) ?: $root, 'root' => $root, 'special' => $input->getOption('special'), 'output' => $input->getArgument('output'), 'templates' => array_filter(array_map('realpath', $input->getOption('template-dir')), 'is_dir'), 'data' => $input->getOption('data-dir'), 'exclude' => $input->getOption('exclude')])]);
     $containerBuilder->compile();
     $this->setContainer($containerBuilder);
 }
开发者ID:castlepointanime,项目名称:brancher,代码行数:37,代码来源:BuildCommand.php

示例6: setConnection

 protected function setConnection()
 {
     $fileLocator = new FileLocator(getcwd());
     $configFile = $fileLocator->locate('rentgen.yml');
     $config = Yaml::parse($configFile);
     $this->connection = new Connection(new ConnectionConfig($config['connection']));
 }
开发者ID:czogori,项目名称:rentgen,代码行数:7,代码来源:PostgresHelper.php

示例7: loadConfig

 /**
  * @param string $file
  * @return array
  */
 public function loadConfig($file = self::DEFAULT_CONFIG)
 {
     $configDirectories = ['./'];
     $locator = new FileLocator($configDirectories);
     $file = $locator->locate($file);
     return json_decode(file_get_contents($file), true);
 }
开发者ID:nidhhoggr,项目名称:loopback-php-generator,代码行数:11,代码来源:Application.php

示例8: testFileNotFound

 /**
  * @expectedException \InvalidArgumentException
  */
 public function testFileNotFound()
 {
     $configDirectories = array(FIXTURES_PATH);
     $locator = new FileLocator($configDirectories);
     $PhpLoader = new PhpLoader($locator);
     $PhpLoader->load($locator->locate('notFound.php'));
 }
开发者ID:gimler,项目名称:guzzle-description-loader,代码行数:10,代码来源:PhpLoaderTest.php

示例9: load

 /**
  * Loads the configuration file data.
  */
 public function load($workingDir)
 {
     $locator = new FileLocator($this->getPotentialDirectories($workingDir));
     $loader = new YamlLoader($locator);
     // Config validation.
     $processor = new Processor();
     $schema = new BuddySchema();
     $files = $locator->locate(static::FILENAME, NULL, FALSE);
     foreach ($files as $file) {
         // After loading the raw data from the yaml file, we validate given
         // configuration.
         $raw = $loader->load($file);
         $conf = $processor->processConfiguration($schema, array('buddy' => $raw));
         if (isset($conf['commands'])) {
             foreach ($conf['commands'] as $command => $specs) {
                 if (!isset($this->commands[$command])) {
                     $this->commands[$command] = array('options' => $specs, 'file' => $file);
                 }
             }
         }
         // In the case 'root' is set, we do not process any parent buddy files.
         if (!empty($values['root'])) {
             break;
         }
     }
     return $this;
 }
开发者ID:derhasi,项目名称:buddy,代码行数:30,代码来源:Config.php

示例10: getStructureMetadata

 /**
  * {@inheritDoc}
  */
 public function getStructureMetadata($type, $structureType = null)
 {
     $cacheKey = $type . $structureType;
     if (isset($this->cache[$cacheKey])) {
         return $this->cache[$cacheKey];
     }
     $this->assertExists($type);
     if (!$structureType) {
         $structureType = $this->getDefaultStructureType($type);
     }
     if (!is_string($structureType)) {
         throw new \InvalidArgumentException(sprintf('Expected string for structureType, got: %s', is_object($structureType) ? get_class($structureType) : gettype($structureType)));
     }
     $cachePath = sprintf('%s/%s%s', $this->cachePath, Inflector::camelize($type), Inflector::camelize($structureType));
     $cache = new ConfigCache($cachePath, $this->debug);
     if ($this->debug || !$cache->isFresh()) {
         $paths = $this->getPaths($type);
         // reverse paths, so that the last path overrides previous ones
         $fileLocator = new FileLocator(array_reverse($paths));
         try {
             $filePath = $fileLocator->locate(sprintf('%s.xml', $structureType));
         } catch (\InvalidArgumentException $e) {
             throw new Exception\StructureTypeNotFoundException(sprintf('Could not load structure type "%s" for document type "%s", looked in "%s"', $structureType, $type, implode('", "', $paths)), null, $e);
         }
         $metadata = $this->loader->load($filePath, $type);
         $resources = [new FileResource($filePath)];
         $cache->write(sprintf('<?php $metadata = \'%s\';', serialize($metadata)), $resources);
     }
     require $cachePath;
     $structure = unserialize($metadata);
     $this->cache[$cacheKey] = $structure;
     return $structure;
 }
开发者ID:kriswillis,项目名称:sulu,代码行数:36,代码来源:StructureMetadataFactory.php

示例11: load

 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.StaticAccess)
  */
 public function load()
 {
     $locator = new FileLocator($this->paths);
     $configFile = $locator->locate('pgca.yml');
     $fileContents = Yaml::parse(file_get_contents($configFile), true);
     $this->config = new Data($fileContents);
 }
开发者ID:anroots,项目名称:pgca,代码行数:11,代码来源:Config.php

示例12: __construct

 public function __construct($configFile)
 {
     $locator = new FileLocator(array(dirname($configFile)));
     $loader = new YamlLoader($locator);
     $processor = new Processor();
     $this->configuration = $processor->processConfiguration(new Definition(), $loader->load($locator->locate(basename($configFile))));
 }
开发者ID:michelezamuner,项目名称:php-reactive-commands-test,代码行数:7,代码来源:Configuration.php

示例13: __construct

    /**
     * 
     * @param string $configDirectories
     * @param string $configFiles
     * @param string $cachePath
     * @param bool $debug
     */
    public function __construct($configDirectories, $configFiles, $cachePath, $debug = false)
    {
        $this->configDirectories = (array) $configDirectories;
        $this->configFiles = (array) $configFiles;
        $this->cachePath = $cachePath . '/faker_config.php';
        $configCache = new ConfigCache($this->cachePath, $debug);
        if (!$configCache->isFresh()) {
            $locator = new FileLocator($this->configDirectories);
            $loaderResolver = new LoaderResolver([new YamlLoader($locator)]);
            $delegatingLoader = new DelegatingLoader($loaderResolver);
            $resources = [];
            $config = [];
            foreach ($this->configFiles as $configFile) {
                $path = $locator->locate($configFile);
                $config = array_merge($config, $delegatingLoader->load($path));
                $resources[] = new FileResource($path);
            }
            $exportConfig = var_export($this->parseRawConfig(isset($config['faker']) ? $config['faker'] : []), true);
            $code = <<<PHP
<?php
return {$exportConfig};
PHP;
            $configCache->write($code, $resources);
        }
        if (file_exists($this->cachePath)) {
            $this->config = (include $this->cachePath);
        }
    }
开发者ID:csanquer,项目名称:fakery-generator,代码行数:35,代码来源:FakerConfig.php

示例14: testInvalid

 /**
  * @expectedException \Symfony\Component\Yaml\Exception\ParseException
  */
 public function testInvalid()
 {
     $configDirectories = array(FIXTURES_PATH);
     $locator = new FileLocator($configDirectories);
     $YamlLoader = new YamlLoader($locator);
     $YamlLoader->load($locator->locate('invalid.yml'));
 }
开发者ID:gimler,项目名称:guzzle-description-loader,代码行数:10,代码来源:YamlLoaderTest.php

示例15: load

 /**
  * {@inheritDoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $configuration = new Configuration();
     $config = $this->processConfiguration($configuration, $configs);
     $this->bindParameters($container, $this->getAlias(), $config);
     // Fallback for missing intl extension
     $intlExtensionInstalled = extension_loaded('intl');
     $container->setParameter('lunetics_locale.intl_extension_installed', $intlExtensionInstalled);
     $iso3166 = array();
     $iso639one = array();
     $iso639two = array();
     $localeScript = array();
     if (!$intlExtensionInstalled) {
         $yamlParser = new YamlParser();
         $file = new FileLocator(__DIR__ . '/../Resources/config');
         $iso3166 = $yamlParser->parse(file_get_contents($file->locate('iso3166-1-alpha-2.yml')));
         $iso639one = $yamlParser->parse(file_get_contents($file->locate('iso639-1.yml')));
         $iso639two = $yamlParser->parse(file_get_contents($file->locate('iso639-2.yml')));
         $localeScript = $yamlParser->parse(file_get_contents($file->locate('locale_script.yml')));
     }
     $container->setParameter('lunetics_locale.intl_extension_fallback.iso3166', $iso3166);
     $mergedValues = array_merge($iso639one, $iso639two);
     $container->setParameter('lunetics_locale.intl_extension_fallback.iso639', $mergedValues);
     $container->setParameter('lunetics_locale.intl_extension_fallback.script', $localeScript);
     $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('validator.xml');
     $loader->load('guessers.xml');
     $loader->load('services.xml');
     $loader->load('switcher.xml');
     $loader->load('form.xml');
     if (!$config['strict_match']) {
         $container->removeDefinition('lunetics_locale.best_locale_matcher');
     }
 }
开发者ID:Sententiaregum,项目名称:LocaleBundle,代码行数:37,代码来源:LuneticsLocaleExtension.php


注:本文中的Symfony\Component\Config\FileLocator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。