本文整理汇总了PHP中midgardmvc_core::read_yaml方法的典型用法代码示例。如果您正苦于以下问题:PHP midgardmvc_core::read_yaml方法的具体用法?PHP midgardmvc_core::read_yaml怎么用?PHP midgardmvc_core::read_yaml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类midgardmvc_core
的用法示例。
在下文中一共展示了midgardmvc_core::read_yaml方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
$path = midgardmvc_core::get_component_path('midgardmvc_core') . '/configuration/defaults.yml';
$yaml = file_get_contents($path);
$this->testConfiguration = midgardmvc_core::read_yaml($yaml);
parent::setUp();
}
示例2: get_configuration
public function get_configuration()
{
if (is_null($this->configuration)) {
$configuration_param = $this->node->get_parameter('midgardmvc_core', 'configuration');
$this->configuration = array();
if ($configuration_param) {
$this->configuration = midgardmvc_core::read_yaml($configuration_param);
}
}
return $this->configuration;
}
示例3: load_manifest_file
/**
* Load a component manifest file
*
* @param string $manifest_file Path of the manifest file
*/
private function load_manifest_file($component, $manifest_file)
{
if (!file_exists($manifest_file)) {
throw new OutOfRangeException("Component manifest {$manifest_file} is not installed");
}
$manifest_yaml = file_get_contents($manifest_file);
$manifest = midgardmvc_core::read_yaml($manifest_yaml);
// Normalize manifest
if (!isset($manifest['version'])) {
$manifest['version'] = '0.0.1devel';
}
if (!isset($manifest['extends'])) {
$manifest['extends'] = null;
} elseif (!isset($this->components_enabled[$manifest['extends']])) {
// Ensure the parent component is always enabled
$this->components_enabled[$manifest['extends']] = array();
}
if (!isset($manifest['requires']) || !is_array($manifest['requires'])) {
$manifest['requires'] = array();
}
// Ensure the required components are always enabled
foreach ($manifest['requires'] as $component_required => $component_info) {
$this->components_enabled[$component_required] = array();
}
if (isset($manifest['process_injector'])) {
// This component has an injector for the process() phase
$this->injectors['process'][$component] = $manifest['process_injector'];
}
if (isset($manifest['template_injector'])) {
// This component has an injector for the template() phase
$this->injectors['template'][$component] = $manifest['template_injector'];
}
if (!isset($manifest['observations'])) {
$manifest['observations'] = array();
}
foreach ($manifest['observations'] as $index => $observation) {
if (!is_array($observation['type'])) {
$observation['type'] = array($observation['type']);
}
if (!is_array($observation['event'])) {
$observation['event'] = array($observation['event']);
}
$manifest['observations'][$index] = $observation;
}
return $manifest;
}
示例4: read_configuration
private static function read_configuration($local_configuration = null)
{
if (is_array($local_configuration)) {
// Configuration passed as a PHP array
return $local_configuration;
} elseif (is_string($local_configuration) && substr($local_configuration, 0, 1) == '/') {
// Application YAML file provided, load configuration from it
if (!file_exists($local_configuration)) {
throw new Exception("Application configuration file {$local_configuration} not found");
}
$configuration_yaml = file_get_contents($local_configuration);
return midgardmvc_core::read_yaml($configuration_yaml);
}
throw new Exception('Unrecognized configuration given for Midgard MVC initialization');
}
示例5: get_configuration
public function get_configuration()
{
if (is_null($this->configuration)) {
// Called for first time, load from YAML file
$this->configuration = midgardmvc_core::read_yaml($this->get_configuration_contents());
}
return $this->configuration;
}
示例6: test_read_yaml_empty
public function test_read_yaml_empty()
{
$yaml = '';
$parsed = midgardmvc_core::read_yaml($yaml);
$this->assertTrue(is_array($parsed));
$this->assertTrue(empty($parsed));
}