Esempio n. 1
0
 static function get($path, $graceful = false)
 {
     // TODO: Implement using http://spyc.sourceforge.net/ if syck is not available
     if ($graceful) {
         $content = midcom_core_helpers_snippet::get_contents_graceful($path);
     } else {
         $content = midcom_core_helpers_snippet::get_contents($path);
     }
     return syck_load($content);
 }
Esempio n. 2
0
 /**
  * Helper function which transforms a raw schema database (either already parsed or
  * based on a URL to a schemadb) into a list of schema class instances.
  *
  * This function may be called statically.
  *
  * @param mixed $raw_db Either an already created raw schema array, or a midgard_get_snippet_content
  *     compatible URL to a snippet / file from which the db should be loaded.
  * @return Array An array of midcom_helper_datamanager_schema class instances.
  * @see midcom_get_snippet_content()
  */
 static function load_database($raw_db)
 {
     $path = null;
     if (is_string($raw_db)) {
         $path = $raw_db;
         try {
             $raw_db = midcom_core_helpers_snippet::get($path);
         } catch (OutOfBoundsException $e) {
             throw new midcom_helper_datamanager_exception_schema("Failed to parse the schema database loaded from '{$path}'");
         }
     }
     $schemadb = array();
     foreach ($raw_db as $name => $raw_schema) {
         $schemadb[$name] = new midcom_helper_datamanager_schema($raw_db, $name, $path);
     }
     return $schemadb;
 }