本文整理汇总了PHP中YAML::Parse方法的典型用法代码示例。如果您正苦于以下问题:PHP YAML::Parse方法的具体用法?PHP YAML::Parse怎么用?PHP YAML::Parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YAML
的用法示例。
在下文中一共展示了YAML::Parse方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetch_fieldset
public static function fetch_fieldset($fieldset)
{
$defaults = array('fields' => array());
if (File::exists("_config/fieldsets/{$fieldset}.yaml")) {
$meta_raw = file_get_contents("_config/fieldsets/{$fieldset}.yaml");
$meta = array_merge($defaults, YAML::Parse($meta_raw));
return $meta;
}
return $defaults;
}
示例2: dirname
if ($page == '') {
$page = '/';
}
$folder = dirname($folder);
$data['full_slug'] = $page;
}
}
// Get/Set Status
if ($data['slug'] === 'page') {
$data['status'] = array_get($data, 'status', Slug::getStatus($data['folder']));
} else {
$data['status'] = array_get($data, 'status', Slug::getStatus($page));
}
if ($data['slug'] != 'page' && File::exists("{$content_root}/{$folder}/fields.yaml")) {
$fields_raw = file_get_contents("{$content_root}/{$folder}/fields.yaml");
$fields_data = YAML::Parse($fields_raw);
if (isset($fields_data['fields'])) {
# fields.yaml controls the fields
$data['fields'] = $fields_data['fields'];
} elseif (isset($fields_data['_fieldset'])) {
# using a fieldset
$fieldset = $fields_data['_fieldset'];
$fs = Statamic_Fieldset::load($fieldset);
$fieldset_data = $fs->get_data();
$data['fields'] = $fieldset_data['fields'];
} else {
# not set.
$data['fields'] = array();
}
$data['type'] = isset($fields_data['type']) && !is_array($fields_data['type']) ? $fields_data['type'] : $fields_data['type']['prefix'];
// Slug
示例3: load
public static function load($username)
{
$meta_raw = "";
if (File::exists("_config/users/{$username}.yaml")) {
$meta_raw = file_get_contents("_config/users/{$username}.yaml");
} else {
return NULL;
}
if (Pattern::endsWith($meta_raw, "---")) {
$meta_raw .= "\n";
# prevent parse failure
}
# Parse YAML Front Matter
if (stripos($meta_raw, "---") === FALSE) {
$meta = YAML::Parse($meta_raw);
$meta['content'] = "";
} else {
list($yaml, $content) = preg_split("/---/", $meta_raw, 2, PREG_SPLIT_NO_EMPTY);
$meta = YAML::Parse($yaml);
$meta['biography_raw'] = trim($content);
$meta['biography'] = Content::transform($content);
$u = new Statamic_User($meta);
$u->set_name($username);
return $u;
}
}