• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP yaml_parse函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: onEnable

 public function onEnable()
 {
     $this->getServer()->getPluginManager()->registerEvents($this, $this);
     if (!is_dir($this->getDataFolder())) {
         mkdir($this->getDataFolder());
     }
     if (!file_exists($this->getDataFolder() . "areas.json")) {
         file_put_contents($this->getDataFolder() . "areas.json", "[]");
     }
     if (!file_exists($this->getDataFolder() . "config.yml")) {
         $c = $this->getResource("config.yml");
         $o = stream_get_contents($c);
         fclose($c);
         file_put_contents($this->getDataFolder() . "config.yml", str_replace("DEFAULT", $this->getServer()->getDefaultLevel()->getName(), $o));
     }
     $this->areas = array();
     $data = json_decode(file_get_contents($this->getDataFolder() . "areas.json"), true);
     foreach ($data as $datum) {
         $area = new Area($datum["name"], $datum["flags"], $datum["pos1"], $datum["pos2"], $datum["level"], $datum["whitelist"], $this);
     }
     $c = yaml_parse(file_get_contents($this->getDataFolder() . "config.yml"));
     $this->god = $c["Default"]["God"];
     $this->edit = $c["Default"]["Edit"];
     $this->touch = $c["Default"]["Touch"];
     $this->levels = array();
     foreach ($c["Worlds"] as $level => $flags) {
         $this->levels[$level] = $flags;
     }
 }
开发者ID:kdani1,项目名称:iProtector,代码行数:29,代码来源:Main.php


示例2: extractContent

 private function extractContent()
 {
     if (!$this->content) {
         //todo use composer yaml parser instead of pecl
         $this->content = yaml_parse(file_get_contents($this->directory . DIRECTORY_SEPARATOR . $this->filename));
     }
 }
开发者ID:lgnap,项目名称:ansible-tags-parser,代码行数:7,代码来源:YamlParser.php


示例3: GetNodeConf

 /**
  * Retrieves the node configuration, loading it if it hasn't been already;
  * 
  * @param string $nodename Name of the node
  * @return Config The node's configuration
  */
 protected static function GetNodeConf($node_uri)
 {
     if (isset(self::$_nodes[$node_uri])) {
         return self::$_nodes[$node_uri];
     }
     $cache = Cache::GetCache('serialization');
     $node = $cache->get($node_uri);
     if (!$node) {
         $filename = PATH_APP . 'map/' . str_replace(".", "/", $node_uri);
         $format = null;
         $data = null;
         if (file_exists($filename . '.js')) {
             $format = "js";
             $data = json_decode(file_get_contents($filename . '.js'), true);
         } else {
             if (file_exists($filename . '.yaml')) {
                 $format = "yaml";
                 $data = yaml_parse(file_get_contents($filename . '.yaml'));
             }
         }
         $map = new Config($data, $filename, $format);
         foreach ($map as $key => $value) {
             self::$_nodes[$key] = $value;
         }
         if (!isset(self::$_nodes[$node_uri])) {
             throw new Exception("Could not find {$node_uri} serialization node.");
         }
     }
     $node = self::$_nodes[$node_uri];
     $cache->set($node_uri, $node);
     return $node;
 }
开发者ID:jawngee,项目名称:HeavyMetal,代码行数:38,代码来源:serializer.php


示例4: parse

 /**
  * Parses the contents of a given YAML file.
  *
  * @param $filePath
  * @throws Exceptions\FileReaderException
  * @return array
  */
 public static function parse($filePath)
 {
     try {
         $data = self::load($filePath);
         if (!empty($data)) {
             //Try to process the yaml file with the PHP function, if installed
             if (function_exists("yaml_parse")) {
                 $dataArray = yaml_parse($data);
                 if (is_array($dataArray)) {
                     return $dataArray;
                 }
             } else {
                 try {
                     $yml = new \Symfony\Component\Yaml\Yaml();
                     return $yml->parse($data);
                 } catch (\Symfony\Component\Yaml\Exception\ParseException $e) {
                     //Do nothing. Fire exception after the if-else statement.
                 }
             }
             throw new FileReaderException('The file does not contain valid well formatted YAML data.');
         } else {
             throw new FileReaderException('No data has been loaded. Use the load($filePath) method before using getData().');
         }
     } catch (FileReaderException $e) {
         throw new FileReaderException($e);
     }
 }
开发者ID:sonrisa,项目名称:filereader-component,代码行数:34,代码来源:YmlFileReader.php


示例5: loadString

 /**
  * @param $text string
  * @return array
  * @throws MWException
  */
 public static function loadString($text)
 {
     global $wgTranslateYamlLibrary;
     switch ($wgTranslateYamlLibrary) {
         case 'phpyaml':
             $ret = yaml_parse($text);
             if ($ret === false) {
                 // Convert failures to exceptions
                 throw new InvalidArgumentException("Invalid Yaml string");
             }
             return $ret;
         case 'spyc':
             // Load the bundled version if not otherwise available
             if (!class_exists('Spyc')) {
                 require_once __DIR__ . '/../libs/spyc/spyc.php';
             }
             $yaml = spyc_load($text);
             return self::fixSpycSpaces($yaml);
         case 'syck':
             $yaml = self::syckLoad($text);
             return self::fixSyckBooleans($yaml);
         default:
             throw new MWException("Unknown Yaml library");
     }
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:30,代码来源:TranslateYaml.php


示例6: onEnable

 public function onEnable()
 {
     @mkdir($this->getDataFolder());
     XcelUpdater::chkUpdate($this);
     if (!is_file($this->getDataFolder() . "shops.json")) {
         file_put_contents($this->getDataFolder() . "shops.json", json_encode([]));
     }
     $shops = json_decode(file_get_contents($this->getDataFolder() . "shops.json"), true);
     $translations = yaml_parse(stream_get_contents($this->getResource("translation.yml")));
     foreach ($translations as $name => $data) {
         ToAruPG::addTranslation($name, $data);
     }
     foreach ($shops as $tag => $meta) {
         switch ($meta["type"]) {
             case "SET":
                 $this->shops[$tag] = new SetShop($meta["meta"], $meta["cost"], $meta["desc"]);
                 break;
             case "JOB":
                 $this->shops[$tag] = new JobShop($meta["meta"], $meta["cost"], $meta["desc"]);
                 break;
             case "SKILL":
                 $this->shops[$tag] = new SkillShop($meta["meta"], $meta["cost"], $meta["desc"]);
                 break;
         }
     }
     $this->getServer()->getPluginManager()->registerEvents($this, $this);
     $this->doubleTap = [];
     $this->itemPlaceList = [];
 }
开发者ID:HelloWorld017,项目名称:ToAruShop,代码行数:29,代码来源:ToAruShop.php


示例7: run

 /**
  * @return InspectionResult
  */
 public function run()
 {
     $result = new InspectionResult("Bad practice");
     $pluginYml = file_get_contents($this->dir . "plugin.yml");
     $manifest = yaml_parse($pluginYml);
     if ($manifest === false) {
         $result->error("Error parsing <code>plugin.yml</code>");
         return $result;
     }
     $mainFile = realpath($this->dir . "src/" . str_replace("\\", "/", $manifest["main"]) . ".php");
     /** @var \SplFileInfo $file */
     foreach (new \RegexIterator(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->dir)), "#\\.php\$#") as $file) {
         $file = $file->getPathname();
         $contents = file_get_contents($file);
         $isMain = $file === $mainFile;
         if (stripos($contents, "server::getinstance()") !== false) {
             $result->warning("<code>Server::getInstance()</code> scanned in file <code>" . substr($file, strlen($this->dir)) . "</code><br>\n\t\t\t\t\t<ul><li>The PHP extensions that PocketMine-MP uses have some issues with\n\t\t\t\t\tstatic properties. You are recommended try using other methods to get\n\t\t\t\t\tthe <code>Server</code> instance.</li>\n\t\t\t\t\t<li>" . ($isMain ? "You can use <code>\$this->getServer()</code> to get the server object instead." : (stripos($contents, "extends PluginTask") !== false ? "You can use <code>\$this->getOwner()->getServer()</code> to get\n\t\t\t\t\t\t\tthe <code>Server</code> instance instead." : "You can pass <code>\$this->getServer()</code> from the plugin object to\n\t\t\t\t\t\t\tyour current class's constructor.")) . "</li></ul>");
         }
         if ($isMain) {
             if (preg_match_all("#\\\$this->config[ \t\r\n]?=[ \t\r\n]?new[ \t\r\n]+config[ \t\r\n]?\\(#i", $contents)) {
                 $result->warning("<code>PluginBase::\$config</code> is already defined in PocketMine\n\t\t\t\t\t\tPluginBase class. Strange errors will occur if you override\n\t\t\t\t\t\t<code>\$this->config</code> yourself. For example, when you decide to use\n\t\t\t\t\t\t<code>\$this->saveDefaultConfig()</code> later, it will not work.<br>\n\t\t\t\t\t\t<ul><li>You are recommended to improve this by renaming <code>\$this->config</code>\n\t\t\t\t\t\tto something else, or to use <code>\$this->saveDefaultConfig()</code> and related\n\t\t\t\t\t\tfunctions.</li></ul>");
             }
         }
     }
     return $result;
 }
开发者ID:1455931078,项目名称:web-server-source,代码行数:29,代码来源:BadPracticeInspection.php


示例8: decode

 /**
  * @param string $data
  * @param string $format
  * @param array  $context
  *
  * @return mixed
  */
 public function decode($data, $format, array $context = array())
 {
     if ($this->native) {
         return yaml_parse($data);
     }
     return $this->decoder->parse($data);
 }
开发者ID:mihai-stancu,项目名称:serializer,代码行数:14,代码来源:YamlEncoder.php


示例9: __invoke

 public function __invoke($data)
 {
     set_error_handler($this->generateErrorHandler($data));
     $parsed = yaml_parse($data);
     restore_error_handler();
     return $parsed;
 }
开发者ID:europaphp,项目名称:component-config,代码行数:7,代码来源:Yml.php


示例10: decode

 public static function decode($yaml)
 {
     $data = yaml_parse($yaml, 0, $ndocs, ['DateTime' => 'self::bsonSerialize', 'Timestamp' => 'self::bsonSerialize', 'ObjectID' => 'self::bsonSerialize', 'Binary' => 'self::bsonSerialize', 'Javascript' => 'self::bsonSerialize', 'Regex' => 'self::bsonSerialize', 'MaxKey' => 'self::bsonSerialize', 'MinKey' => 'self::bsonSerialize']);
     if (!is_array($data)) {
         throw new \Exception('Not yaml format');
     }
     return $data;
 }
开发者ID:tany,项目名称:php-note,代码行数:8,代码来源:Yaml.php


示例11: _config

 private static function _config()
 {
     $configFile = self::_configFile();
     if (file_exists($configFile)) {
         $config = yaml_parse(@file_get_contents($configFile));
     }
     return (array) $config;
 }
开发者ID:iamfat,项目名称:gini,代码行数:8,代码来源:Index.php


示例12: parse

 public static function parse($content)
 {
     if (self::$native === false) {
         $yaml = new \Symfony\Component\Yaml\Yaml();
         return new Collection($yaml->parse($content));
     } else {
         return new Collection(yaml_parse($content));
     }
 }
开发者ID:gregorybellencontre,项目名称:Sybil-Framework,代码行数:9,代码来源:Yaml.php


示例13: loadFile

 /**
  * Loads in the given file and parses it.
  *
  * @param string $file File to load
  *
  * @return string|array|stdClass The parsed file data
  *
  * @since              0.2.4
  * @codeCoverageIgnore
  */
 protected function loadFile($file = null)
 {
     $this->file = $file;
     $contents = $this->parseVars(Utils::getContent($file));
     if (extension_loaded('yaml')) {
         return yaml_parse($contents);
     }
     return YamlParser::parse($contents);
 }
开发者ID:xeriab,项目名称:konfig,代码行数:19,代码来源:Yaml.php


示例14: load

 /**
  * Loads configuration from YAML.
  *
  * @param   mixed   $source
  *
  * @return  array
  */
 public function load($source)
 {
     if (is_resource($source)) {
         $source = stream_get_contents($source);
     } elseif (file_exists($source)) {
         $source = file_get_contents($source);
     }
     return yaml_parse($source);
 }
开发者ID:rsky,项目名称:PEAR_PackageFileBuilder,代码行数:16,代码来源:YamlLoader.php


示例15: loadString

 public static function loadString($input)
 {
     if (extension_loaded('yaml')) {
         return yaml_parse($input);
     }
     sfYaml::setSpecVersion('1.1');
     // more compatible
     $parser = new sfYamlParser();
     return $parser->parse($input);
 }
开发者ID:piotras,项目名称:pake,代码行数:10,代码来源:pakeYaml.class.php


示例16: yamlDataProvider

 public function yamlDataProvider()
 {
     $class = str_replace('Nl2Go\\Templates\\', '', static::class);
     $filename = str_replace('\\', DIRECTORY_SEPARATOR, $class);
     $filename = sprintf('tests/%s.yaml', $filename);
     $trace = debug_backtrace(false, 3);
     $method = $trace[2]['args'][2];
     $testdata = yaml_parse(file_get_contents($filename));
     return $testdata['tests'][$method]['dataProvider'];
 }
开发者ID:hielsnoppe,项目名称:php-goodies,代码行数:10,代码来源:YamlDataProviderTrait.php


示例17: __construct

 function __construct($configFile)
 {
     $config = yaml_parse(file_get_contents($configFile));
     $num = 0;
     $this->apiKey = $config["APIKey"];
     $this->voteUrl = $config["VoteURL"];
     $this->ranks = $config["Ranks"];
     $this->autoRanks = $config["AutoRanks"];
     $this->voteRanks = $config["VoteRanks"];
     $this->messages = $config["Messages"];
 }
开发者ID:RedstoneAlmeida,项目名称:VoteRanks,代码行数:11,代码来源:Config.php


示例18: getRepoVersion

 public static function getRepoVersion($pluginYamlURL)
 {
     $curl = curl_init($pluginYamlURL);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
     curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
     curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
     $data = curl_exec($curl);
     curl_close($curl);
     return yaml_parse($data)["version"];
 }
开发者ID:organization,项目名称:XcelUpdater,代码行数:11,代码来源:XcelUpdater.php


示例19: load

 public static function load($name, $section = 'default')
 {
     static $caches = [];
     if (isset($caches[$key = "{$name}--{$section}"])) {
         return $caches[$key];
     }
     $conf = yaml_parse(load_file(ROOT . "/conf/default/{$name}.yml"))[$section];
     if (is_file($file = ROOT . "/conf/{$name}.yml")) {
         $conf = array_replace_recursive($conf, yaml_parse(load_file($file))[$section]);
     }
     return $caches[$key] = $conf;
 }
开发者ID:tany,项目名称:php-note,代码行数:12,代码来源:Config.php


示例20: test_serialization

 public function test_serialization()
 {
     $path = realpath(dirname(__FILE__)) . '/../../configuration/defaults.yml';
     $data = yaml_parse(file_get_contents($path));
     $serialized = yaml_emit($data);
     $serialized2 = $this->_core->configuration->serialize($data);
     if ($serialized === $serialized2) {
         $this->assertTrue(true);
     } else {
         $this->assertTrue(false);
     }
 }
开发者ID:piotras,项目名称:midgardmvc_core,代码行数:12,代码来源:configuration.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP yaml_parse_file函数代码示例发布时间:2022-05-23
下一篇:
PHP yaml_emit函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap