本文整理汇总了PHP中Spyc类的典型用法代码示例。如果您正苦于以下问题:PHP Spyc类的具体用法?PHP Spyc怎么用?PHP Spyc使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Spyc类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例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);
}
示例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');
}
}
}
}
}
}
}
示例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;
}
示例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;
}
示例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';
}
}
}
示例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;
}
}
示例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);
}
示例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;
}
示例10: read
static function read($filename)
{
if (!file_exists($filename)) {
trigger_error("YAML error: file '{$filename}' does not exist");
}
return Spyc::YAMLLoad($filename);
}
示例11: read
public function read()
{
if (file_exists($this->file)) {
$configuration = file_get_contents($this->file);
$this->registry = \Spyc::YAMLLoadString($configuration);
}
}
示例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');
}
示例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;
}
示例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);
}
}
示例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');
}