Exemplo n.º 1
0
 function &_get_typed_value($value)
 {
     # value is a string
     if (is_string($value)) {
         # tagged value
         if (preg_match('/^!!(autowire|service|property|constant)\\s+(.+)$/', $value, $matches)) {
             switch ($matches[1]) {
                 case 'autowire':
                     $string = $matches[2];
                     if (strstr($string, '::')) {
                         list($filename, $clazz) = explode('::', $string);
                         if (!class_exists($clazz)) {
                             if (!is_file($this->base . $filename) || !file_exists($this->base . $filename)) {
                                 show_error('Instantiator Error', "File not found for '{$clazz}': " . $this->base . $filename);
                             }
                             include $this->base . $filename;
                         }
                     } else {
                         $clazz = $string;
                     }
                     $value =& AppContext::createAutowiredService($clazz);
                     break;
                 case 'service':
                     $service = $matches[2];
                     $point =& AppContext::servicePoint($service);
                     if ($point == NULL) {
                         show_error('Instantiator Error', 'Undefined service-point: ' . $service);
                     }
                     $value =& $point->instance();
                     break;
                 case 'property':
                     $value = AppContext::property($matches[2]);
                     break;
                 case 'constant':
                     $value = constant($matches[2]);
                     break;
             }
         }
     } else {
         if (is_array($value)) {
             # recurse
             $newvalue = array_map(array(&$this, '_get_typed_value'), &$value);
             $value =& $newvalue;
         }
     }
     return $value;
 }