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


PHP Spyc::YAMLLoad方法代码示例

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


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

示例1: edit

 /**
  * edit
  *
  * @return void
  */
 public function edit()
 {
     //リクエストセット
     if ($this->request->is('post')) {
         //登録処理
         if (!$this->request->data['SiteSetting']['only_session']) {
             unset($this->request->data['SiteSetting']['only_session']);
             $this->Session->write('debug', null);
             //application.ymlに書き込み
             $conf = Spyc::YAMLLoad(APP . 'Config' . DS . 'application.yml');
             $conf['debug'] = (int) $this->request->data['SiteSetting']['debug']['0']['value'];
             $file = new File(APP . 'Config' . DS . $this->appYmlPrefix . 'application.yml', true);
             $file->write(Spyc::YAMLDump($conf));
             $this->SiteManager->saveData();
         } else {
             $this->SiteSetting->validateDeveloper($this->request->data);
             if (!$this->SiteSetting->validationErrors) {
                 $this->Session->write('debug', (int) $this->request->data['SiteSetting']['debug']['0']['value']);
                 $this->NetCommons->setFlashNotification(__d('net_commons', 'Successfully saved.'), array('class' => 'success'));
                 $this->redirect($this->referer());
             } else {
                 $this->NetCommons->handleValidationError($this->SiteSetting->validationErrors);
             }
         }
     } else {
         $this->request->data['SiteSetting'] = $this->SiteSetting->getSiteSettingForEdit(array('SiteSetting.key' => array('debug')));
         $onlySession = $this->Session->read('debug');
         $this->request->data['SiteSetting']['only_session'] = isset($onlySession);
         if ($this->request->data['SiteSetting']['only_session']) {
             $this->request->data['SiteSetting']['debug']['0']['value'] = $onlySession;
         }
     }
 }
开发者ID:NetCommons3,项目名称:SystemManager,代码行数:38,代码来源:DeveloperController.php

示例2: remoteFunction

 function remoteFunction(&$controller, $options)
 {
     $javascript_options = JavascriptHelper::optionsForAjax($options);
     $update = '';
     if (isset($options['update']) && is_string($options['update'])) {
         require_once 'vendor/spyc.php';
         $val = @Spyc::YAMLLoad($options['update']);
         if (!empty($val)) {
             // it's a YAML array, so load it into options['update']
             $options['update'] = $val;
         }
     }
     if (isset($options['update']) && is_array($options['update'])) {
         $update = array();
         if (isset($options['update']['success'])) {
             $update[] = "success:'{$options['update']['success']}'";
         }
         if (isset($options['update']['failure'])) {
             $update[] = "failure:'{$options['update']['failure']}'";
         }
         $update = implode(',', $update);
     } else {
         if (isset($options['update'])) {
             $update = $options['update'];
         }
     }
     $function = isset($options['update']) ? "new Ajax.Updater('{$update}', " : 'new Ajax.Request(';
     $function .= "'" . UrlHelper::urlFor($controller, $options['url']) . "'";
     $function .= ', ' . $javascript_options . ')';
     $function = (isset($options['before']) ? "{$options['before']}; " : '') . $function;
     $function .= isset($options['after']) ? "; {$options['after']};" : '';
     $function = isset($options['condition']) ? 'if(' . $options['condition'] . '){' . $function . '}' : $function;
     $function = isset($options['confirm']) ? 'if(confirm' . $options['condition'] . '){' . $function . '}' : $function;
     return $function;
 }
开发者ID:nonfiction,项目名称:nterchange,代码行数:35,代码来源:javascript_helper.php

示例3: _read

 protected function _read()
 {
     $settingsFile = CONFIGS . DS . 'settings.php';
     include $settingsFile;
     if (!isset($settings)) {
         trigger_error(sprintf(__('Missing settings file[%s] or $settings could not be found', true), $settingsFile));
         return array();
     }
     $records = $this->find('all');
     foreach ($records as $record) {
         switch ($record['Setting']['name']) {
             case 'per_page_options':
                 $settings[$record['Setting']['name']] = explode(',', $record['Setting']['value']);
                 break;
             case 'issue_list_default_columns':
                 $settings[$record['Setting']['name']] = Spyc::YAMLLoad($record['Setting']['value']);
                 // array_slice(array_map('trim',explode('- ',$v['Setting']['value'])),1);
                 break;
             default:
                 $settings[$record['Setting']['name']] = $record['Setting']['value'];
         }
     }
     Cache::write(self::$__cacheKey, $settings);
     return $settings;
 }
开发者ID:hiromi2424,项目名称:candycane_clone,代码行数:25,代码来源:setting.php

示例4: i18n

function i18n($prompt, $lang)
{
    $fileName = 'locales/' . $lang . '.yml';
    // Retrieve complete list of translations as a single string
    $yaml = Spyc::YAMLLoad($fileName);
    $contents = $yaml[$lang];
    $promptArray = explode(".", $prompt);
    $result = $contents;
    for ($i = 0; $i < count($promptArray); $i++) {
        if (is_array($result)) {
            $result = $result[$promptArray[$i]];
        } else {
            if (isset($result)) {
                return $result;
            } else {
                return $prompt;
            }
        }
    }
    if (isset($result)) {
        return $result;
    } else {
        return $prompt;
    }
}
开发者ID:TundraGreen,项目名称:caminodelcobre,代码行数:25,代码来源:language.php

示例5: compile_apps_yaml

function compile_apps_yaml()
{
    # Load Spyc and serialize apps.yaml.
    include 'spyc.lib.php';
    $data = Spyc::YAMLLoad('apps.yaml');
    return serialize($data);
}
开发者ID:9miles,项目名称:instantinstall,代码行数:7,代码来源:compile_installer.php

示例6: subTest

 function subTest($p, $s)
 {
     //	we really need do this right and to set up a yaml module that abstracts away the underlying yaml engine
     include_once zoop_dir . '/spyc/spyc.php';
     $array = Spyc::YAMLLoad($_SERVER['HOME'] . '/.zoop/install.yaml');
     print_r($array);
 }
开发者ID:laiello,项目名称:zoop,代码行数:7,代码来源:ZoneTest.php

示例7: find

 function find($conditions = null, $fields = array(), $order = null, $recursive = null)
 {
     if ($conditions != 'range') {
         return parent::find($conditions, $fields, $order, $recursive);
     }
     $file = Set::extract($fields, 'file');
     if (empty($file)) {
         $file = ROOT . DS . APP_DIR . DS . 'plugins/mobileip/config/mobile_ips.yml';
     }
     if (!file_exists($file)) {
         return false;
     }
     $cacheDir = $this->getCacheDir();
     $folder = new Folder($cacheDir);
     $folder->create($cacheDir, 0777);
     $cacheFile = $this->getCacheFile();
     if (file_exists($cacheFile) && $this->_getLastModified($file) <= filemtime($cacheFile)) {
         return include $cacheFile;
     }
     $mobile_ips =& Spyc::YAMLLoad($file);
     if (!is_array($mobile_ips)) {
         return false;
     }
     $data = $this->_get_ranges($mobile_ips);
     $file = new File($cacheFile, true);
     $file->write($data);
     $file->close();
     return include $cacheFile;
 }
开发者ID:kaz29,项目名称:mobileip,代码行数:29,代码来源:mobile_ip.php

示例8: versionCheck

 /**
  * versionCheck - Get the most current version of nterchange and cache the result.
  *
  * @return 	array 	Information about the newest version of nterchange.
  **/
 function versionCheck()
 {
     require_once 'Cache/Lite.php';
     $options = array('cacheDir' => CACHE_DIR . '/ntercache/', 'lifeTime' => $this->check_version_interval);
     $cache = new Cache_Lite($options);
     $yaml = $cache->get($this->cache_name, $this->cache_group);
     if (empty($yaml)) {
         include_once 'HTTP/Request.php';
         $req = new HTTP_Request($this->check_version_url);
         if (!PEAR::isError($req->sendRequest())) {
             $yaml = $req->getResponseBody();
             $cached = $cache->save($yaml, $this->cache_name, $this->cache_group);
             if ($cached == true) {
                 NDebug::debug('Version check - data is from the web and is now cached.', N_DEBUGTYPE_INFO);
             } else {
                 NDebug::debug('Version check - data is from the web and is NOT cached.', N_DEBUGTYPE_INFO);
             }
         }
     } else {
         NDebug::debug('Version check - data is from the cache.', N_DEBUGTYPE_INFO);
     }
     require_once 'vendor/spyc.php';
     $newest_version_info = @Spyc::YAMLLoad($yaml);
     return $newest_version_info;
 }
开发者ID:nonfiction,项目名称:nterchange,代码行数:30,代码来源:version_check_controller.php

示例9: 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

示例10: load

 /**
  * Load config file
  *
  * Get array from config file and save it to variable
  *
  * @static
  * @access   public
  * @param    string $sConfigPath
  * @param    string $sFormat
  * @return   bool
  * @throws   Exception
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 private static function load($sConfigPath, $sFormat = 'php')
 {
     $oConfigData = static::findConfigFile($sConfigPath, $sFormat);
     // load config data
     if ($oConfigData !== FALSE) {
         switch ($sFormat) {
             # PHP
             case 'php':
                 $aConfig = (include $oConfigData->getPath());
                 break;
                 # YAML
             # YAML
             case "yml":
                 $aConfig = \Spyc::YAMLLoad($oConfigData->getPath());
                 break;
         }
     }
     // assign data to storage
     if (isset($aConfig)) {
         Helper\Arrays::createMultiKeys(static::$aConfigs, $sConfigPath, $aConfig);
         unset($aConfig);
         Log::insert('Config ' . $sConfigPath . ' (' . $sFormat . ') loaded');
         return TRUE;
     }
     // if there is no data to assign (because the config file does not exists), create ERROR message and return FALSE (or throw exception)
     $sMsg = 'Unable to load ' . $sConfigPath . ' config file with "' . $sFormat . '" format.';
     Log::insert($sMsg, Log::ERROR);
     if (Core::getAppMode() === Core::MODE_DEVELOPMENT) {
         throw new Exception($sMsg);
     }
     return FALSE;
 }
开发者ID:ktrzos,项目名称:plethora,代码行数:46,代码来源:Config.php

示例11: __construct

 function __construct()
 {
     # Include the SPYC library for yaml parsing:
     require_once '3rd-party/spyc/spyc.php';
     # Loads an array with the config:
     $this->aConfig = Spyc::YAMLLoad('config.yml');
 }
开发者ID:jorgefuertes,项目名称:qPlanet,代码行数:7,代码来源:Config.class.php

示例12: main

 /**
  * The method that runs the task
  *
  * @return void
  */
 public function main()
 {
     $this->map = Spyc::YAMLLoad($this->mapFile);
     if (!isset($this->map['symlinks'])) {
         throw new Exception("Invalid symlinks map file", 1);
     }
 }
开发者ID:OSTraining,项目名称:AllediaBuilder,代码行数:12,代码来源:MappedSymlinksTask.php

示例13: doTheHooks

function doTheHooks($name, $branch, $repo, $transport)
{
    $result = null;
    chdir($repo['dir']);
    ob_start();
    echo "~> git pull origin " . $branch . " 3>&1\n";
    system(__ENV_PATH__ . ' ' . __GIT_PATH__ . ' pull origin ' . $branch . ' 2>&1');
    echo "\n";
    if (file_exists($repo['dir'] . '/' . __HOOKS_FILE__)) {
        $yaml = Spyc::YAMLLoad($repo['dir'] . '/' . __HOOKS_FILE__);
        $cmds = array();
        if (is_array($yaml[$repo['branch']])) {
            $cmds = $yaml[$repo['branch']];
        } elseif (is_array($yaml['all'])) {
            $cmds = $yaml['all'];
        }
        foreach ($cmds as $cmd) {
            echo "~> " . $cmd . "\n";
            system(__ENV_PATH__ . ' ' . $cmd);
            echo "\n";
        }
        $result = ob_get_contents();
        if (is_array($yaml['emails'])) {
            foreach ($yaml['emails'] as $email) {
                $mailer = Swift_Mailer::newInstance($transport);
                $message = Swift_Message::newInstance()->setSubject(sprintf(__MAIL_SUBJECT__, $name))->setFrom(array(__MAIL_FROM_ADDRESS__ => __MAIL_FROM__))->setTo(array($email))->setBody($result);
                $result = $mailer->send($message);
            }
        }
    }
    ob_end_clean();
}
开发者ID:betacie,项目名称:webhooks,代码行数:32,代码来源:core.php

示例14: parse

 /**
  * Parse a block of YAML into PHP
  *
  * @param string  $yaml  YAML-formatted string to parse
  * @param string  $mode  Parsing mode to use
  * @return array
  */
 public static function parse($yaml, $mode = null)
 {
     // start measuring
     $hash = Debug::markStart('parsing', 'yaml');
     $mode = $mode ? $mode : self::getMode();
     switch ($mode) {
         case 'loose':
             $result = Spyc::YAMLLoad($yaml);
             break;
         case 'strict':
             $result = sYAML::parse($yaml);
             break;
         case 'transitional':
             try {
                 $result = sYaml::parse($yaml);
             } catch (Exception $e) {
                 Log::error($e->getMessage() . ' Falling back to loose mode.', 'core', 'yaml');
                 $result = Spyc::YAMLLoad($yaml);
             }
             break;
         default:
             $result = Spyc::YAMLLoad($yaml);
     }
     // end measuring
     Debug::markEnd($hash);
     Debug::increment('parses', 'yaml');
     return $result;
 }
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:35,代码来源:yaml.php

示例15: setUp

 protected function setUp()
 {
     global $SAP_CONFIG;
     $this->config = Spyc::YAMLLoad($SAP_CONFIG);
     echo "sapnwrfc version: " . sapnwrfc_version() . "\n";
     echo "nw rfc sdk version: " . sapnwrfc_rfcversion() . "\n";
 }
开发者ID:ThaDafinser,项目名称:php-sapnwrfc,代码行数:7,代码来源:ReadTableTest.php


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