當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。