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

PHP syck_load函数代码示例

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

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



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

示例1: load

 /**
  * Load configuration file by it's type and put it into a Zend_Config object
  *
  * @param  string $configFile Configuration file path
  * @param  string $fileType   Configuration file type
  * @param  string $section    Configuration section to load
  * @return Zend_Config
  */
 public static function load($configFile, $fileType = self::YAML, $section = 'default')
 {
     switch ($fileType) {
         case self::YAML:
             $yaml = file_get_contents($configFile);
             if (extension_loaded('syck')) {
                 $data = syck_load($yaml);
             } else {
                 require_once 'Spyc.php';
                 $data = Spyc::YAMLLoad($yaml);
             }
             require_once 'Zend/Config.php';
             return new Zend_Config($data[$section]);
             break;
         case self::INI:
             require_once 'Zend/Config/Ini.php';
             return new Zend_Config_Ini($configFile, $section);
             break;
         case self::XML:
             require_once 'Zend/Config/Xml.php';
             return new Zend_Config_Xml($configFile, $section);
             break;
         default:
             require_once 'Spizer/Exception.php';
             throw new Spizer_Exception("Configuration files of type '{$fileType}' are not (yet?) supported");
             break;
     }
 }
开发者ID:highestgoodlikewater,项目名称:spizer,代码行数:36,代码来源:Config.php


示例2: load_translation_file

 protected function load_translation_file($file)
 {
     if (!function_exists('syck_load'))
         throw new SI18nException('Syck extension is not installed');
         
     return syck_load(file_get_contents($file));
 }
开发者ID:Kervinou,项目名称:OBM,代码行数:7,代码来源:yaml.php


示例3: loadFile

 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);
         }
     }
 }
开发者ID:apinstein,项目名称:phocoa,代码行数:30,代码来源:WFYaml.php


示例4: load

 public static function load($filename)
 {
     // cache object
     #        $oCache = Days_Cache::instance();
     // load configuration file from cache
     #        if ($oCache->isCached($filename)) {
     #            $config = $oCache->getCache($filename);
     #        }
     // load configuration file and set to cache
     #        else {
     // check file
     if (!file_exists($filename)) {
         throw new Days_Exception("Configuration file '{$filename}' not found");
     }
     // use fast Yaml module for php (if exists)
     if (function_exists('syck_load')) {
         $config = syck_load(file_get_contents($filename));
     } else {
         $config = Spyc::YAMLLoad($filename);
     }
     // renew cache
     #            $oCache->setCache($filename, $config);
     #        }
     // return result array
     return $config;
 }
开发者ID:laiello,项目名称:phpdays,代码行数:26,代码来源:Yaml.php


示例5: load

 public function load($file_name)
 {
     if (($file = file_get_contents($file_name)) !== false) {
         return syck_load($file);
     }
     YamlErrors::fileNotFound($file_name);
     return null;
 }
开发者ID:Nivl,项目名称:Ninaca_1,代码行数:8,代码来源:SyckYaml.class.php


示例6: get

 static function get($path, $graceful = false)
 {
     // TODO: Implement using http://spyc.sourceforge.net/ if syck is not available
     if ($graceful) {
         $content = midcom_core_helpers_snippet::get_contents_graceful($path);
     } else {
         $content = midcom_core_helpers_snippet::get_contents($path);
     }
     return syck_load($content);
 }
开发者ID:abbra,项目名称:midcom,代码行数:10,代码来源:snippet.php


示例7: load_yaml

 /**
  *  Loads any .yml file
  *  @return array
  */
 private static function load_yaml($config_file)
 {
     if (is_readable($config_file)) {
         if (function_exists("syck_load")) {
             return syck_load(file_get_contents($config_file));
         } else {
             return Spyc::YAMLLoad($config_file);
         }
     } else {
         return false;
     }
 }
开发者ID:phpwax,项目名称:phpwax,代码行数:16,代码来源:Config.php


示例8: testSimple

    public function testSimple()
    {
        $yaml = <<<YAML
---
define: &pointer_to_define
   - 1
   - 2
   - 3
reference: *pointer_to_define
YAML;
        $arr = syck_load($yaml);
        $this->assertEquals($arr['define'], $arr['reference']);
    }
开发者ID:andreassylvester,项目名称:syck,代码行数:13,代码来源:TestMerge.php


示例9: load

 public static function load($input)
 {
     // syck is prefered over spyc
     if (function_exists('syck_load')) {
         if (!empty($input) && is_readable($input)) {
             $input = file_get_contents($input);
         }
         return syck_load($input);
     } else {
         $spyc = new pakeSpyc();
         return $spyc->load($input);
     }
 }
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:13,代码来源:pakeYaml.class.php


示例10: process

 /**
  * Transform data and return the result.
  *
  * @param string $data  Yaml string or file
  * @return array
  */
 public function process($data)
 {
     if ($this->chainInput) {
         $data = $this->chainInput->process($data);
     }
     if ($data instanceof Fs_Node) {
         $data = $data->getContents();
     } else {
         $data = (string) $data;
     }
     $data = syck_load($data);
     return $data;
 }
开发者ID:jasny,项目名称:Q,代码行数:19,代码来源:Yaml.php


示例11: yaml_load

function yaml_load($input = null)
{
    if (is_null($input)) {
        return array();
    }
    $input = yaml_include_contents($input);
    if (is_array($input)) {
        return $input;
    }
    if (function_exists('syck_load')) {
        $datas = syck_load($input);
        return is_array($datas) ? $datas : array();
    } else {
        return spyc_load($input);
    }
}
开发者ID:sofadesign,项目名称:vincent-helye.com,代码行数:16,代码来源:yaml.php


示例12: load

 /**
  * Load YAML into a PHP array statically
  *
  * The load method, when supplied with a YAML stream (string or file),
  * will do its best to convert YAML in a file into a PHP array.
  *
  *  Usage:
  *  <code>
  *   $array = sfYAML::Load('config.yml');
  *   print_r($array);
  *  </code>
  *
  * @return array
  * @param string $input Path of YAML file or string containing YAML
  */
 public static function load($input)
 {
     $input = self::getIncludeContents($input);
     // if an array is returned by the config file assume it's in plain php form else in yaml
     if (is_array($input)) {
         return $input;
     }
     // syck is prefered over spyc
     if (function_exists('syck_load')) {
         $retval = syck_load($input);
         return is_array($retval) ? $retval : array();
     } else {
         require_once dirname(__FILE__) . '/Spyc.class.php';
         $spyc = new Spyc();
         return $spyc->load($input);
     }
 }
开发者ID:Daniel-Marynicz,项目名称:symfony1-legacy,代码行数:32,代码来源:sfYaml.class.php


示例13: loadString

	/**
	 * @param $text string
	 * @return array
	 * @throws MWException
	 */
	public static function loadString( $text ) {
		global $wgTranslateYamlLibrary;

		switch ( $wgTranslateYamlLibrary ) {
			case 'spyc':
				require_once( dirname( __FILE__ ) . '/../spyc/spyc.php' );
				$yaml = spyc_load( $text );
				return self::fixSpycSpaces( $yaml );
			case 'syck':
				$yaml = self::syckLoad( $text );
				return self::fixSyckBooleans( $yaml );
			case 'syck-pecl':
				$text = preg_replace( '~^(\s*)no(\s*:\s*[a-zA-Z-_]+\s*)$~m', '\1"no"\2', $text );
				return syck_load( $text );
			default:
				throw new MWException( "Unknown Yaml library" );
		}
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:23,代码来源:TranslateYaml.php


示例14: load

 public static function load($string, $forgiving = false)
 {
     if (substr($string, 0, 3) != '---') {
         $string = "---\n{$string}";
     }
     try {
         // if syck is available use it
         if (extension_loaded('syck')) {
             return syck_load($string);
         }
         // if not, use the symfony YAML parser
         $yaml = new sfYamlParser();
         return $yaml->parse($string);
     } catch (Exception $e) {
         if ($forgiving) {
             // if YAML document is not correct,
             // but we're forgiving, use the Spyc parser
             return Spyc::YAMLLoadString($string);
         }
         throw new Wikidot_Yaml_Exception("Can't parse the YAML string." . $e->getMessage());
     }
 }
开发者ID:jbzdak,项目名称:wikidot,代码行数:22,代码来源:Yaml.php


示例15: loadWithSource

 private function loadWithSource($Source)
 {
     if (empty($Source)) {
         return array();
     }
     if ($this->setting_use_syck_is_possible && function_exists('syck_load')) {
         $array = syck_load(implode("\n", $Source));
         return is_array($array) ? $array : array();
     }
     $this->path = array();
     $this->result = array();
     $cnt = count($Source);
     for ($i = 0; $i < $cnt; $i++) {
         $line = $Source[$i];
         $this->indent = strlen($line) - strlen(ltrim($line));
         $tempPath = $this->getParentPathByIndent($this->indent);
         $line = self::stripIndent($line, $this->indent);
         if (self::isComment($line)) {
             continue;
         }
         if (self::isEmpty($line)) {
             continue;
         }
         $this->path = $tempPath;
         $literalBlockStyle = self::startsLiteralBlock($line);
         if ($literalBlockStyle) {
             $line = rtrim($line, $literalBlockStyle . " \n");
             $literalBlock = '';
             $line .= ' ' . $this->LiteralPlaceHolder;
             $literal_block_indent = strlen($Source[$i + 1]) - strlen(ltrim($Source[$i + 1]));
             while (++$i < $cnt && $this->literalBlockContinues($Source[$i], $this->indent)) {
                 $literalBlock = $this->addLiteralLine($literalBlock, $Source[$i], $literalBlockStyle, $literal_block_indent);
             }
             $i--;
         }
         // Strip out comments
         if (strpos($line, '#')) {
             $line = preg_replace('/\\s*#([^"\']+)$/', '', $line);
         }
         while (++$i < $cnt && self::greedilyNeedNextLine($line)) {
             $line = rtrim($line, " \n\t\r") . ' ' . ltrim($Source[$i], " \t");
         }
         $i--;
         $lineArray = $this->_parseLine($line);
         if ($literalBlockStyle) {
             $lineArray = $this->revertLiteralPlaceHolder($lineArray, $literalBlock);
         }
         $this->addArray($lineArray, $this->indent);
         foreach ($this->delayedPath as $indent => $delayedPath) {
             $this->path[$indent] = $delayedPath;
         }
         $this->delayedPath = array();
     }
     return $this->result;
 }
开发者ID:eroonkang,项目名称:typojanchi2015,代码行数:55,代码来源:Spyc.php


示例16: eval

echo "+----------+{$br}";
if (function_exists('date_create')) {
    eval('class MyDateTime extends DateTime {
        static public function create($timestamp) {
            return new MyDateTime($timestamp);
        }
        public function __toString() {
            return $this->format(self::ISO8601);
        }
    }');
    var_dump($y = yaml_parse($data, 0, $ndocs, array('tag:yaml.org,2002:timestamp' => array('MyDateTime', 'create'))));
} else {
    var_dump($y = yaml_parse($data));
}
echo $br;
echo "+----------+{$br}";
echo "|   Syck   |{$br}";
echo "+----------+{$br}";
var_dump($s = syck_load($data));
$s = array();
echo $br;
echo "+----------+{$br}";
echo "|   diff   |{$br}";
echo "+----------+{$br}";
if (gettype($y) != gettype($s)) {
    var_dump(false);
} elseif (is_array($y)) {
    var_dump(array_diff($y, $s));
} else {
    var_dump($y == $s);
}
开发者ID:e-user,项目名称:php-yaml,代码行数:31,代码来源:test4.php


示例17: parseSchema

 /**
  *
  * @param $file
  * @return unknown_type
  */
 public function parseSchema($file)
 {
     if (!extension_loaded('syck')) {
         throw new Exception('The syck extension is required');
     }
     // One can also use this: Doctrine_Parser::load('test.yml', 'yml');
     /* load the yaml data from the filesystem */
     try {
         $schema = syck_load(file_get_contents('/srv/www/courses/htdocs/Data/Db/courses_schema.yml'));
     } catch (SyckException $e) {
         echo self::INVALID_SCHEMA;
         echo $e->getMessage();
         echo $e->getFile();
         echo $e->getLine();
     }
     return $schema;
 }
开发者ID:Neozeratul,项目名称:Intermodels,代码行数:22,代码来源:Form.php


示例18: startMigration

 function startMigration($file, $direction)
 {
     $yml = $this->_parsePhp($file);
     if (function_exists('syck_load')) {
         $array = @syck_load($yml);
     } else {
         vendor('Spyc');
         $array = Spyc::YAMLLoad($yml);
     }
     if (!is_array($array)) {
         return "Unable to parse YAML Migration file";
     }
     if (!$array[up($direction)]) {
         return "Direction does not exist!";
     }
     return $this->_array_to_sql($array[up($direction)]);
 }
开发者ID:Jewgonewild,项目名称:Twitter-Oauth-CakePHP,代码行数:17,代码来源:migrate.php


示例19: _buildMenu

 private static function _buildMenu()
 {
     $app = KX_CURRENT_APP;
     if (KX_CURRENT_APP == 'core' && !isset(kxEnv::$request['module']) && !isset(kxEnv::$request['app'])) {
         $modules = array(array('module_file' => 'index'));
     } else {
         $modules = kxDB::getinstance()->select("modules", "", array('fetch' => PDO::FETCH_ASSOC))->fields("modules", array("module_name", "module_file"))->condition("module_application", $app)->condition("module_manage", 1)->orderBy("module_position")->execute()->fetchAll();
     }
     //print_r($modules);
     foreach ($modules as $module) {
         $_file = kxFunc::getAppDir($app) . "/modules/manage/" . $module['module_file'] . '/menu.yml';
         //echo "<p>Getting menu from {$_file}</p>";
         if (file_exists($_file)) {
             if (function_exists("syck_load")) {
                 $menu[$module['module_file']] = syck_load(file_get_contents($_file));
             } else {
                 $menu[$module['module_file']] = spyc_load_file($_file);
             }
             self::assign('menu', $menu);
             self::assign('module', $module['module_file']);
         }
     }
 }
开发者ID:D4rk4,项目名称:Kusaba-z,代码行数:23,代码来源:kxTemplate.class.php


示例20: testLargeArrays

 public function testLargeArrays()
 {
     $obj = range(1, 10000);
     $this->assertSame($obj, syck_load(syck_dump($obj)));
 }
开发者ID:andreassylvester,项目名称:syck,代码行数:5,代码来源:TestDump.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP symbol函数代码示例发布时间:2022-05-23
下一篇:
PHP sybase_unbuffered_query函数代码示例发布时间: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