本文整理汇总了PHP中Spyc类的典型用法代码示例。如果您正苦于以下问题:PHP Spyc类的具体用法?PHP Spyc怎么用?PHP Spyc使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Spyc类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: CargarArchivoYAMLAplicacion
/**
* SysMisNeural::CargarArchivoYAMLAplicacion($Ruta);
*
* Metodo para cargar los archivos YAML que se encuentran dentro de la carpeta Aplicacion
* @param $Ruta: se utilliza la el nombre de la caperta / archivo
* Ejemplo: SysMisNeural::CargarArchivoYAMLAplicacion('Configuracion/Archivo.yaml');
*
**/
public static function CargarArchivoYAMLAplicacion($Ruta)
{
//Validacion de Activacion de Cache
if (__SysNeuralCoreCache__ == 'HABILITADO') {
$RutaArray = explode('/', $Ruta);
$AplicacionArray = explode('.', $RutaArray[1]);
$Llave = md5($AplicacionArray[0]);
$Cache = new NeuralCacheSimple('NeuralNFZyosSetUp', $Llave);
$Cache->DefinirTiempoExpiracion(__SysNeuralCoreCacheExpiracion__);
if ($Cache->ExistenciaCache(base64_encode($Llave))) {
return $Cache->ObtenerCache(base64_encode($Llave));
} else {
//Leemos el archivo de configuracion de accesos y lo convertimos en un array
$YML = new Spyc();
$Array = $YML->YAMLLoad(__SysNeuralFileRootAplicacion__ . $Ruta);
$Cache->GuardarCache($Llave, $Array);
return $Array;
}
} else {
//Leemos el archivo de configuracion de accesos y lo convertimos en un array
$YML = new Spyc();
$Array = $YML->YAMLLoad(__SysNeuralFileRootAplicacion__ . $Ruta);
return $Array;
}
}
开发者ID:rigocastillo,项目名称:TCU,代码行数:33,代码来源:SysMisNeural.php
示例2: saveIntoDatabase
/**
* Mostly rewritten from parent, but allows circular dependencies - goes through the relation loop only after
* the dictionary is fully populated.
*/
public function saveIntoDatabase(DataModel $model)
{
// Custom plumbing: this has to be executed only once per fixture.
$testDataTag = basename($this->fixtureFile);
$this->latestVersion = DB::query("SELECT MAX(\"Version\") FROM \"TestDataTag\" WHERE \"FixtureFile\"='{$testDataTag}'")->value();
// We have to disable validation while we import the fixtures, as the order in
// which they are imported doesnt guarantee valid relations until after the
// import is complete.
$validationenabled = DataObject::get_validation_enabled();
DataObject::set_validation_enabled(false);
$parser = new Spyc();
$fixtureContent = $parser->loadFile($this->fixtureFile);
$this->fixtureDictionary = array();
foreach ($fixtureContent as $dataClass => $items) {
if (ClassInfo::exists($dataClass)) {
$this->writeDataObject($model, $dataClass, $items);
} else {
$this->writeSQL($dataClass, $items);
}
}
// Dictionary is now fully built, inject the relations.
foreach ($fixtureContent as $dataClass => $items) {
if (ClassInfo::exists($dataClass)) {
$this->writeRelations($dataClass, $items);
}
}
DataObject::set_validation_enabled($validationenabled);
}
开发者ID:helpfulrobot,项目名称:silverstripe-testdata,代码行数:32,代码来源:TestDataYamlFixture.php
示例3: requireDefaultRecords
public function requireDefaultRecords()
{
parent::requireDefaultRecords();
// get schemas that need creating
$schemas = $this->config()->get('default_schemas');
require_once 'spyc/spyc.php';
foreach ($schemas as $file) {
if (file_exists(Director::baseFolder() . '/' . $file)) {
$parser = new Spyc();
$factory = new FixtureFactory();
$fixtureContent = $parser->loadFile(Director::baseFolder() . '/' . $file);
if (isset($fixtureContent['MetadataSchema'])) {
$toBuild = array();
// check if it exists or not, if so don't re-create it
foreach ($fixtureContent['MetadataSchema'] as $id => $desc) {
$name = isset($desc['Name']) ? $desc['Name'] : null;
if (!$name) {
throw new Exception("Cannot create metadata schema without a name");
}
$existing = MetadataSchema::get()->filter('Name', $name)->first();
if ($existing) {
$factory->setId('MetadataSchema', $id, $existing->ID);
} else {
$factory->createObject('MetadataSchema', $id, $desc);
DB::alteration_message('Metadata schema ' . $id . ' created', 'created');
}
}
// don't need this now
unset($fixtureContent['MetadataSchema']);
// go through and unset any existing fields
$toBuild = array();
foreach ($fixtureContent as $class => $items) {
foreach ($items as $identifier => $data) {
$nameField = isset($data['Name']) ? 'Name' : (isset($data['Key']) ? 'Key' : '');
if (!strlen($nameField)) {
throw new Exception("Metadata fields must have a Name or Key field defined");
}
if (!isset($data['Title'])) {
$data['Title'] = $data[$nameField];
}
$existing = $class::get()->filter($nameField, $data[$nameField])->first();
if ($existing) {
$factory->setId($class, $identifier, $existing->ID);
} else {
$factory->createObject($class, $identifier, $data);
DB::alteration_message('Metadata field ' . $data[$nameField] . ' created', 'created');
}
}
}
}
}
}
}
开发者ID:helpfulrobot,项目名称:silverstripe-australia-metadata,代码行数:53,代码来源:MetadataSchema.php
示例4: __construct
public function __construct()
{
$base = Site::model('Environment')->database_atheist_tables_base;
$page = Site::model('Environment')->database_atheist_tables_page;
$page['fields'] = array_merge($base['fields'], $page['fields']);
$dbPage = 'page';
$dbPage = $this->describe('profiles_fields');
echo '<pre>';
print_r($dbPage);
echo $this->create_table($dbPage);
echo '=====';
$spyc = new Spyc();
echo $spyc->YAMLDump($dbPage, true);
die;
}
开发者ID:cheevauva,项目名称:trash,代码行数:15,代码来源:Backend.php
示例5: 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
示例6: __construct
function __construct($database_type, $db_file)
{
$Data = Spyc::YAMLLoad(BMARK . 'db.yaml');
if ($database_type == 'mysql') {
$this->database_type = $database_type;
$this->user = $Data['mysqld']['user'];
$this->pass = $Data['mysqld']['pass'];
$this->host = $Data['mysqld']['host'];
$this->port = $Data['mysqld']['port'];
$this->database = $Data['mysqld']['dbname'];
$this->connection = '';
}
if ($database_type == 'drizzle') {
$this->database_type = $database_type;
$this->user = $Data['drizzled']['user'];
$this->pass = $Data['drizzled']['pass'];
$this->host = $Data['drizzled']['host'];
$this->port = $Data['drizzled']['port'];
$this->database = $Data['drizzled']['dbname'];
$this->connection = '';
}
if (strlen($this->port) <= 0) {
if (strcmp($this->database_type, "mysql") == 0) {
$this->port = '3306';
}
if (strcmp($this->database_type, "drizzle") == 0) {
$this->port = '4427';
}
}
}
开发者ID:barce,项目名称:partition_benchmarks,代码行数:30,代码来源:Dao.php
示例7: 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
示例8: 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
示例9: 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
示例10: read
static function read($filename)
{
if (!file_exists($filename)) {
trigger_error("YAML error: file '{$filename}' does not exist");
}
return Spyc::YAMLLoad($filename);
}
开发者ID:laiello,项目名称:zoop,代码行数:7,代码来源:Yaml.php
示例11: read
public function read()
{
if (file_exists($this->file)) {
$configuration = file_get_contents($this->file);
$this->registry = \Spyc::YAMLLoadString($configuration);
}
}
开发者ID:aoloe,项目名称:php-configuration,代码行数:7,代码来源:Configuration.php
示例12: __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
示例13: output
function output()
{
global $config, $pages, $ums, $blog, $user, $coms, $editor;
//First Requirements (Components)
$error = "";
foreach ($pages['pacedit']['reqs'] as $req) {
if (!in_array($req, $config['coms'])) {
$error .= "Component: " . $req . " is missing<br>";
}
}
if ($error != "") {
$out = $error;
} else {
if (!in_array($user['id'], $coms['pacman']['admins'])) {
$out = "You are not a package manager";
} else {
$out = "<h1>Package Manager - Edit</h1>";
if (!$_GET['pac']) {
$out .= 'Please Go back and try again';
} else {
$com = $_GET['pac'];
$content = Spyc::YAMLDump($coms[$com]);
$out .= '<form action="?var=pacsub" method="POST">
<input type="hidden" value="' . $com . '" name="com" />
<textarea name="yaml" id="yaml" cols="70" rows="15">' . str_replace("- --\n", '', $content) . '</textarea><input type="submit" value="Save" /></form>';
}
}
}
return $out;
}
开发者ID:Arcath,项目名称:arcath.net-yaml-cms,代码行数:30,代码来源:edit.php
示例14: 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
示例15: getAll
/**
* Gets all labels for a defined type.
*
* @param string $type Name of the array group.
* @param string $locale Locale code.
*
* @access public
* @static
* @uses Config()
* @uses \Spyc
*
* @return array
*/
public static function getAll($type, $locale = '')
{
if (!$locale) {
$locale = Core\Registry()->get('locale');
}
return \Spyc::YAMLLoad(Core\Config()->paths('labels') . $locale . DIRECTORY_SEPARATOR . $type . '.yaml');
}
开发者ID:weareathlon,项目名称:silla.io,代码行数:20,代码来源:yaml.php
示例16: _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
示例17: 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
示例18: beforeSave
function beforeSave($options = array())
{
if ($this->data[$this->name]['type'] == 'IssueCustomField' && !empty($this->data['CustomField']['id'])) {
$assoc_trackers = Set::extract('{n}.CustomFieldsTracker.tracker_id', $this->CustomFieldsTracker->find('all', array('conditions' => array('custom_field_id' => $this->data['CustomField']['id']))));
$tracker_ids = empty($this->data[$this->name]['tracker_id']) ? array() : $this->data[$this->name]['tracker_id'];
$this->__add_trackers = array_diff($tracker_ids, $assoc_trackers);
$this->__del_trackers = array_diff($assoc_trackers, $tracker_ids);
}
unset($this->data[$this->name]['tracker_id']);
App::Import('vendor', 'spyc');
if (!empty($this->data[$this->name]['possible_values']) && $this->data[$this->name]['field_format'] == 'list') {
if (empty($this->data[$this->name]['possible_values'][count($this->data[$this->name]['possible_values']) - 1])) {
unset($this->data[$this->name]['possible_values'][count($this->data[$this->name]['possible_values']) - 1]);
}
$this->data[$this->name]['possible_values'] = Spyc::YAMLDump($this->data[$this->name]['possible_values'], true);
} else {
$this->data[$this->name]['possible_values'] = '--- []';
}
if (empty($this->data[$this->name]['min_length'])) {
$this->data[$this->name]['min_length'] = 0;
}
if (empty($this->data[$this->name]['max_length'])) {
$this->data[$this->name]['max_length'] = 0;
}
return true;
}
开发者ID:nachtschatt3n,项目名称:candycane,代码行数:26,代码来源:custom_field.php
示例19: 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
示例20: 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
注:本文中的Spyc类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论