當前位置: 首頁>>代碼示例>>PHP>>正文


PHP syck_load函數代碼示例

本文整理匯總了PHP中syck_load函數的典型用法代碼示例。如果您正苦於以下問題:PHP syck_load函數的具體用法?PHP syck_load怎麽用?PHP syck_load使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了syck_load函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的syck_load函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。