本文整理汇总了PHP中spyc_load_file函数的典型用法代码示例。如果您正苦于以下问题:PHP spyc_load_file函数的具体用法?PHP spyc_load_file怎么用?PHP spyc_load_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了spyc_load_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
public static function load($file, $cache = 3600)
{
if ($cache > 0 && RUN_MODE == 'deploy') {
import('system/bin/cache');
$cache_instance = CacheBackend::get_instance();
$cache_id = 'yaml_' . str_replace(array('/', '.'), '_', $file);
if ($cache_instance->is_cached($cache_id)) {
return $cache_instance->get($cache_id);
} else {
if (!is_file($file)) {
$file = Package::get_file($file);
if (!is_file($file)) {
return array();
}
}
import('system/vendors/spyc/spyc');
$info = spyc_load_file($file);
$cache_instance->set($cache_id, $info);
return $info;
}
}
if (!is_file($file)) {
$file = Package::get_file($file);
if (!is_file($file)) {
return array();
}
}
import('system/vendors/spyc/spyc');
$info = spyc_load_file($file);
return $info;
}
示例2: parseConfigFile
function parseConfigFile($name, $loadDefaults, $disableDefaults = false)
{
global $magicDefaultsFolder;
global $magicRootFolder;
$baseFile = "{$magicDefaultsFolder}/{$name}.defaults.yml";
$overrideFile = "{$magicRootFolder}/{$name}.yml";
if ($loadDefaults) {
$config = spyc_load_file($baseFile);
if (file_exists($overrideFile)) {
$override = spyc_load_file($overrideFile);
if ($disableDefaults) {
foreach ($config as $key => &$spell) {
$spell['enabled'] = false;
}
}
$config = array_replace_recursive($config, $override);
}
} else {
$config = spyc_load_file($overrideFile);
}
if (count($config) == 1 && $config[0] == 0) {
$config = array();
}
return $config;
}
示例3: get
/**
* Get
* Get Value based on Key
* @param string $dataKey
* @return mixed
*/
public function get($dataKey, $default = '[RAMLDataObject]')
{
if (!isset($this->data[$dataKey])) {
$dataKey = strtoupper($dataKey);
}
if (!isset($this->data[$dataKey])) {
if ($default != '[RAMLDataObject]') {
return $default;
}
return new RAMLDataObject();
// shoudl return false
} elseif (is_array($this->data[$dataKey])) {
$t = new RAMLDataObject($this->data[$dataKey]);
$t->setMaster($this->master);
return $t;
// convert to preg_match_all
} elseif (is_string($this->data[$dataKey]) && preg_match('/^\\!include ([a-z_\\.\\/]+)/i', $this->data[$dataKey], $matches)) {
$ext = array_pop(explode('.', $matches[1]));
if (in_array($ext, array('yaml', 'raml'))) {
$t = new RAMLDataObject(spyc_load_file($matches[1]));
$t->setMaster($this);
return $t;
}
return file_get_contents($matches[1]);
} elseif ($dataKey == 'schema') {
$this->data[$dataKey] = $this->master->handleSchema($this->data[$dataKey]);
}
return $this->master->handlePlaceHolders($this->data[$dataKey]);
}
示例4: parse
public function parse($fname)
{
$filename = ROOT_PATH . "/" . Makiavelo::MAPPINGS_FOLDER . "/" . $fname;
if ($filename) {
return spyc_load_file($filename);
}
}
示例5: is_authentic
/**
* 判断用户权限
*/
protected function is_authentic()
{
if (!isset($_SESSION["admin_id"]) || $_SESSION["admin_id"] < 1) {
$this->redirect("/login");
}
$ADMINSTRATOR = in_array($_SESSION['admin_id'], explode(",", C('ADMINSTRATOR'))) ? true : false;
if ($ADMINSTRATOR) {
return true;
}
$role = spyc_load_file("./Conf/role.yml");
$role_id = isset($_SESSION['role_id']) ? "role_" . $_SESSION['role_id'] : "role_4";
if (!isset($role[$role_id]) || $role[$role_id]["status"] != 1) {
$this->show("你所属的角色已禁用或已删除!");
exit;
}
$roles = explode(",", $role[$role_id]["action"]);
$ModuleAction = MODULE_NAME . "/" . ACTION_NAME;
$user_role = true;
if (in_array($ModuleAction, $roles)) {
$user_role = false;
}
if ($role[$role_id]["status"] != 1) {
$user_role = false;
}
if (!$user_role) {
$this->show("操作失败,权限不足");
exit;
}
}
示例6: generateModel
public function generateModel($yaml_file, $dir)
{
$schema = spyc_load_file($yaml_file);
$this->dir = $dir;
foreach ($schema as $entity_name => $entity_definition) {
$this->generateClass($dir . '/' . $entity_name . '.class.php', $entity_name, $entity_definition);
}
}
示例7: loadYaml
public function loadYaml($filename)
{
if (file_exists($filename)) {
return spyc_load_file($filename);
} else {
return null;
}
}
示例8: gp_load_yaml
/**
* Loads a YAML file into an array. First checks the child tempate's file, then the framework's
*/
function gp_load_yaml($filename)
{
$file = locate_template($filename, false, false);
if ($file) {
return gp_process_yaml_array(spyc_load_file($file));
} else {
return false;
}
}
示例9: createSchema
public function createSchema($yaml_file)
{
$schema = spyc_load_file($yaml_file);
foreach ($schema as $entity_name => $entity_definition) {
$this->createTable($entity_name, $entity_definition);
if ($entity_definition['relations']['many-to-many']) {
$this->createManyToManyRelations($entity_definition['relations']['many-to-many'], $entity_name);
}
}
}
示例10: __construct
/**
* Config constructor.
* @param string $pathToConfigFile
* @throws ConfigParseException
*/
public function __construct($pathToConfigFile)
{
$pathToConfigFile = trim($pathToConfigFile);
if (!file_exists($pathToConfigFile) || !is_readable($pathToConfigFile)) {
throw new \InvalidArgumentException("The config file at path: '{$pathToConfigFile}' was not found and/or is not readable");
}
try {
$this->config = spyc_load_file($pathToConfigFile);
} catch (\Exception $e) {
throw new ConfigParseException("There was an error parsing the config file at path: '{$pathToConfigFile}'." . " Error Message: '{$e->getMessage()}'");
}
}
示例11: load_file
private function load_file($file)
{
if (!file_exists($file)) {
die("Failute at yaml config parse. '{$file}' doesnt exsist");
}
if (function_exists('yaml_parse_file')) {
return yaml_parse_file($file);
}
if (function_exists('spyc_load_file')) {
return spyc_load_file($file);
}
die('Failure at yaml config parse. No tool available to reach this goal');
}
示例12: getPluginUpdates
private function getPluginUpdates($pluginDir)
{
$plugin_conf = spyc_load_file($this->pluginsDir . '/' . $pluginDir . "/plugin.yaml");
if (!isset($plugin_conf['update_url'])) {
return;
}
if (!isset($plugin_conf['version'])) {
return;
}
$update_url = $plugin_conf['update_url'];
$version = $plugin_conf['version'];
$updates = json_decode(file_get_contents($update_url . '?version=' . $version));
return $updates;
}
示例13: get_left_admin_nav
public function get_left_admin_nav($ADMINSTRATOR, $role_id, $array_id, $now_id = 0)
{
if ($this->nav_arr_model === null) {
$nav_arr = spyc_load_file("./Conf/nav.yml");
$nav = $this->nav_arr_model = new ArrayModel($nav_arr);
} else {
$nav = $this->nav_arr_model;
}
$where["pid"] = array("eq", $now_id);
$left_nav = $nav->where($where)->order("sort asc")->select();
if (!$left_nav) {
return '';
}
$item = "";
foreach ($left_nav as $v) {
if ($v["enable"] != 1 || $v["show"] != 1) {
continue;
//如果此节点已停用或者不显示在导航栏,进入下一次循环
}
if (in_array($v["id"], $array_id) && !$ADMINSTRATOR) {
continue;
//如果无此节点权限,进入下一次循环
}
$url = $v["url"] == "#" || $v["url"] == "" ? "javascript:void();" : U($v["url"]);
$item .= "<dl id=\"nav_{$v['id']}\">\n";
$item .= "<dt>{$v['names']}</dt>";
$map["pid"] = array("eq", $v['id']);
$left_nav_list = $nav->where($map)->order("sort asc")->select();
foreach ($left_nav_list as $list) {
if ($list["enable"] != 1 || $list["show"] != 1) {
continue;
//如果此节点已停用或者不显示在导航栏,进入下一次循环
}
if (in_array($list["id"], $array_id) && !$ADMINSTRATOR) {
continue;
//如果无此节点权限,进入下一次循环
}
$list_url = $list["url"] == "#" || $list["url"] == "" ? "javascript:void();" : U($list["url"]);
$item .= "<dd id=\"nav_{$list['id']}\">\r\n <span onclick=\"javascript:gourl('{$list['id']}','{$list_url}')\"><a href=\"{$list_url}\" target=\"main\">{$list['names']}</a></span>\n";
$item .= $this->get_left_admin_nav($ADMINSTRATOR, $role_id, $array_id, $list['id']);
$item .= "</dd>";
}
$item .= "</dl>";
}
if ($now_id == 0) {
F("admin_left_nav_" . $role_id, $item);
}
return $item;
}
示例14: load
static function load($template)
{
$blueprint = c::get('root.site') . '/' . c::get('panel.folder') . '/blueprints/' . $template . '.php';
// custom default
if ($template != 'default' && !file_exists($blueprint)) {
$blueprint = c::get('root.site') . '/' . c::get('panel.folder') . '/blueprints/default.php';
}
// default fallback
if (!file_exists($blueprint)) {
$blueprint = c::get('root.panel') . '/defaults/blueprints/default.php';
}
$params = spyc_load_file($blueprint);
// add the default fields
$params = self::defaultFields($params);
return $params;
}
示例15: _getDatabaseConnectionParameters
/**
* Read database connection parameters from local.xml file
*
* @return array
* @throws Exception
*/
protected function _getDatabaseConnectionParameters()
{
// Get Yml Reader if not already present
if (!class_exists('Spyc')) {
$currentPath = __DIR__;
$vendorPos = strpos(strtolower($currentPath), 'vendor');
if (!$vendorPos) {
throw new Exception("Composer Vendor Directory not found in current Path, needed to require Spyc.");
}
$include = substr($currentPath, 0, $vendorPos) . 'vendor/mustangostang/spyc/Spyc.php';
require_once $include;
}
$localYmlFile = 'app/config/parameters.yml';
if (!is_file($localYmlFile)) {
throw new Exception(sprintf('File "%s" not found', $localYmlFile));
}
$config = spyc_load_file($localYmlFile);
if ($config === false) {
throw new Exception(sprintf('Could not load yml file "%s"', $localYmlFile));
}
return array('host' => (string) $config['parameters']['database_host'], 'database' => (string) $config['parameters']['database_name'], 'username' => (string) $config['parameters']['database_user'], 'password' => (string) $config['parameters']['database_password']);
}