本文整理汇总了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;
}
}
}
示例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;
}
示例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;
}
示例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;
}
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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');
}
示例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);
}
}
示例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();
}
示例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;
}
示例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";
}