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


PHP Yaml::load方法代码示例

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


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

示例1: loadClassMetadata

 /**
  * {@inheritDoc}
  */
 public function loadClassMetadata(ClassMetadata $metadata)
 {
     if (null === $this->classes) {
         $this->classes = Yaml::load($this->file);
     }
     // TODO validation
     if (isset($this->classes[$metadata->getClassName()])) {
         $yaml = $this->classes[$metadata->getClassName()];
         if (isset($yaml['constraints'])) {
             foreach ($this->parseNodes($yaml['constraints']) as $constraint) {
                 $metadata->addConstraint($constraint);
             }
         }
         if (isset($yaml['properties'])) {
             foreach ($yaml['properties'] as $property => $constraints) {
                 foreach ($this->parseNodes($constraints) as $constraint) {
                     $metadata->addPropertyConstraint($property, $constraint);
                 }
             }
         }
         if (isset($yaml['getters'])) {
             foreach ($yaml['getters'] as $getter => $constraints) {
                 foreach ($this->parseNodes($constraints) as $constraint) {
                     $metadata->addGetterConstraint($getter, $constraint);
                 }
             }
         }
         return true;
     }
     return false;
 }
开发者ID:janmarek,项目名称:Neuron,代码行数:34,代码来源:YamlFileLoader.php

示例2: load

 /**
  * Loads a Yaml file.
  *
  * @param string $file A Yaml file path
  * @param string $type The resource type
  *
  * @return RouteCollection A RouteCollection instance
  *
  * @throws \InvalidArgumentException When route can't be parsed
  */
 public function load($file, $type = null)
 {
     $path = $this->locator->locate($file);
     $config = Yaml::load($path);
     $collection = new RouteCollection();
     $collection->addResource(new FileResource($path));
     // empty file
     if (null === $config) {
         $config = array();
     }
     // not an array
     if (!is_array($config)) {
         throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $file));
     }
     foreach ($config as $name => $config) {
         $config = $this->normalizeRouteConfig($config);
         if (isset($config['resource'])) {
             $type = isset($config['type']) ? $config['type'] : null;
             $prefix = isset($config['prefix']) ? $config['prefix'] : null;
             $this->setCurrentDir(dirname($path));
             $collection->addCollection($this->import($config['resource'], $type, false, $file), $prefix);
         } elseif (isset($config['pattern'])) {
             $this->parseRoute($collection, $name, $config, $path);
         } else {
             throw new \InvalidArgumentException(sprintf('Unable to parse the "%s" route.', $name));
         }
     }
     return $collection;
 }
开发者ID:nickaggarwal,项目名称:sample-symfony2,代码行数:39,代码来源:YamlFileLoader.php

示例3: load

 /**
  * Load configuration for a given command.
  * Loading happens only once, after that cached info is returned
  *
  * @param string $file  Config file path
  *
  * @return array Array of loaded config data
  */
 private function load($file)
 {
     if (null === $this->command) {
         $this->command = Yaml::load($file);
     }
     return $this->command;
 }
开发者ID:negativespace,项目名称:phrozn,代码行数:15,代码来源:Command.php

示例4: load

 /**
  * {@inheritdoc}
  */
 public function load($resource, $locale, $domain = 'messages')
 {
     $messages = Yaml::load($resource);
     $catalogue = parent::load($messages, $locale, $domain);
     $catalogue->addResource(new FileResource($resource));
     return $catalogue;
 }
开发者ID:rsky,项目名称:symfony,代码行数:10,代码来源:YamlFileLoader.php

示例5: __construct

 /**
  * Create phrozn command 
  *
  * @param array $paths Folder paths
  */
 public function __construct($paths)
 {
     // load main config
     $config = Yaml::load($paths['configs'] . 'phrozn.yml');
     parent::__construct($config['command']);
     $this->configureCommand($paths, $config); // load all necessary sub-commands
 }
开发者ID:ntulip,项目名称:phrozn,代码行数:12,代码来源:Parser.php

示例6: __construct

 /**
  * Create runner
  *
  * @param \Phrozn\Autoloader $loader Instance of auto-loader
  * @param array $paths Folder paths
  */
 public function __construct($loader)
 {
     $this->paths = $loader->getPaths();
     $this->loader = $loader;
     // load main config
     $this->config = Yaml::load($this->paths['configs'] . 'phrozn.yml');
 }
开发者ID:negativespace,项目名称:phrozn,代码行数:13,代码来源:CommandLine.php

示例7: __construct

 /**
  * @throws InvalidArgumentException from sfYaml::load
  * @throws Zend_Config_Exception
  * @param string $filename
  * @param boolean $allowModifications
  */
 public function __construct($filename, $allowModifications = false)
 {
     $this->filename = $filename;
     $this->checkIfFilenameIsFile();
     $content = SymfonyYaml::load($this->filename);
     if (is_null($content)) {
         $content = array();
     }
     parent::__construct($content, $allowModifications);
 }
开发者ID:NilsLangner,项目名称:LiveTest,代码行数:16,代码来源:Yaml.php

示例8: __construct

 public function __construct()
 {
     parent::__construct();
     //Load Configuration
     $locator = new FileLocator(CFG_PATH);
     $this->setConfig(Yaml::load($locator->locate('config.yml')));
     //Load Extensions
     $this->loadExtensions();
     //Add template globals
     $this->defineTemplateGlobals();
 }
开发者ID:rdohms,项目名称:Sample-Azure-App,代码行数:11,代码来源:Application.php

示例9: __construct

 /**
  * Setup config aggregator
  *
  * @param string $path Path to config folder
  *
  * @return
  */
 public function __construct($path)
 {
     $dir = new \DirectoryIterator($path);
     foreach ($dir as $item) {
         if ($item->isFile()) {
             if (substr($item->getBasename(), -3) === 'yml') {
                 $this->configs[$item->getBasename('.yml')] = Yaml::load($item->getRealPath());
             }
         }
     }
     $this->updatePaths(); // make sure that config.yml paths are absolute
 }
开发者ID:ntulip,项目名称:phrozn,代码行数:19,代码来源:Config.php

示例10: load

 /**
  * Loads the sitemap tree from config or cache
  * If loading from config, caches the result
  *
  * @return NodePub\Navigation\SitemapTree
  */
 public function load()
 {
     $sitemapTree = new SitemapTree('root');
     $sitemapTree->setIsRoot(true);
     $cache = new SitemapCache($this->cacheFile);
     if ($serializedArray = $cache->load()) {
         $sitemapTree->unserialize($serializedArray);
     } elseif (is_file($this->configFile)) {
         $sitemapTree = $this->expandChildNodes($parent, Yaml::load($this->configFile));
         $cache->cacheSerializedArray($sitemapTree->serialize());
     }
     return $sitemapTree;
 }
开发者ID:nodepub,项目名称:navigation,代码行数:19,代码来源:SitemapLoader.php

示例11: load

 /**
  * {@inheritdoc}
  */
 public function load($resource, $locale, $domain = 'messages')
 {
     $messages = Yaml::load($resource);
     // empty file
     if (null === $messages) {
         $messages = array();
     }
     // not an array
     if (!is_array($messages)) {
         throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $resource));
     }
     $catalogue = parent::load($messages, $locale, $domain);
     $catalogue->addResource(new FileResource($resource));
     return $catalogue;
 }
开发者ID:faridos,项目名称:ServerGroveLiveChat,代码行数:18,代码来源:YamlFileLoader.php

示例12: loadClassMetadata

 /**
  * {@inheritDoc}
  */
 public function loadClassMetadata(ClassMetadata $metadata)
 {
     if (null === $this->classes) {
         $this->classes = Yaml::load($this->file);
         // empty file
         if (null === $this->classes) {
             return false;
         }
         // not an array
         if (!is_array($this->classes)) {
             throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $this->file));
         }
         if (isset($this->classes['namespaces'])) {
             foreach ($this->classes['namespaces'] as $prefix => $namespace) {
                 $this->namespaces[$prefix] = $namespace;
             }
             unset($this->classes['namespaces']);
         }
     }
     // TODO validation
     if (isset($this->classes[$metadata->getClassName()])) {
         $yaml = $this->classes[$metadata->getClassName()];
         if (isset($yaml['constraints'])) {
             foreach ($this->parseNodes($yaml['constraints']) as $constraint) {
                 $metadata->addConstraint($constraint);
             }
         }
         if (isset($yaml['properties'])) {
             foreach ($yaml['properties'] as $property => $constraints) {
                 foreach ($this->parseNodes($constraints) as $constraint) {
                     $metadata->addPropertyConstraint($property, $constraint);
                 }
             }
         }
         if (isset($yaml['getters'])) {
             foreach ($yaml['getters'] as $getter => $constraints) {
                 foreach ($this->parseNodes($constraints) as $constraint) {
                     $metadata->addGetterConstraint($getter, $constraint);
                 }
             }
         }
         return true;
     }
     return false;
 }
开发者ID:faridos,项目名称:ServerGroveLiveChat,代码行数:48,代码来源:YamlFileLoader.php

示例13: getMetadata

 /**
  * Get an array of ClassMetadataInfo instances from the passed
  * Doctrine 1 schema
  *
  * @return array $metadatas  An array of ClassMetadataInfo instances
  */
 public function getMetadata()
 {
     $schema = array();
     foreach ($this->_from as $path) {
         if (is_dir($path)) {
             $files = glob($path . '/*.yml');
             foreach ($files as $file) {
                 $schema = array_merge($schema, (array) \Symfony\Component\Yaml\Yaml::load($file));
             }
         } else {
             $schema = array_merge($schema, (array) \Symfony\Component\Yaml\Yaml::load($path));
         }
     }
     $metadatas = array();
     foreach ($schema as $className => $mappingInformation) {
         $metadatas[] = $this->_convertToClassMetadataInfo($className, $mappingInformation);
     }
     return $metadatas;
 }
开发者ID:OmondiKevin,项目名称:ADT_MTRH,代码行数:25,代码来源:ConvertDoctrine1Schema.php

示例14: _load

 /**
  * @inheritdoc
  */
 protected function _load($file)
 {
     $array = Yaml::load($file);
     if (isset($array['name'])) {
         $this->setName($array['name']);
     }
     if (isset($array['table_name'])) {
         $this->setMigrationsTableName($array['table_name']);
     }
     if (isset($array['migrations_namespace'])) {
         $this->setMigrationsNamespace($array['migrations_namespace']);
     }
     if (isset($array['migrations_directory'])) {
         $migrationsDirectory = $this->_getDirectoryRelativeToFile($file, $array['migrations_directory']);
         $this->setMigrationsDirectory($migrationsDirectory);
         $this->registerMigrationsFromDirectory($migrationsDirectory);
     }
     if (isset($array['migrations']) && is_array($array['migrations'])) {
         foreach ($array['migrations'] as $migration) {
             $this->registerMigration($migration['version'], $migration['class']);
         }
     }
 }
开发者ID:faridos,项目名称:ServerGroveLiveChat,代码行数:26,代码来源:YamlConfiguration.php

示例15: loadFile

 protected function loadFile($file)
 {
     return $this->validate(Yaml::load($file), $file);
 }
开发者ID:jackbravo,项目名称:symfony-sandbox,代码行数:4,代码来源:YamlFileLoader.php


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