コード例 #1
0
 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
0
ファイル: midgard2.php プロジェクト: bergie/midgardmvc_core
 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
0
ファイル: midgardmvc.php プロジェクト: bergie/midgardmvc_core
 /**
  * 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
0
ファイル: interface.php プロジェクト: bergie/midgardmvc_core
 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
0
ファイル: midgardmvc.php プロジェクト: bergie/midgardmvc_core
 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
0
ファイル: coreTest.php プロジェクト: bergie/midgardmvc_core
 public function test_read_yaml_empty()
 {
     $yaml = '';
     $parsed = midgardmvc_core::read_yaml($yaml);
     $this->assertTrue(is_array($parsed));
     $this->assertTrue(empty($parsed));
 }