get_file_component() public static method

public static get_file_component ( $file )
Beispiel #1
0
 public function get_component()
 {
     $components = array();
     foreach ($this->trace as $item) {
         try {
             if (isset($item['class'])) {
                 if (!is_object($item['class']) and !class_exists($item['class'], false)) {
                     continue;
                 }
                 if (!method_exists($item['class'], $item['function'])) {
                     continue;
                 }
                 $ref = new ReflectionMethod($item['class'], $item['function']);
                 $file = $ref->getFileName();
             } else {
                 if (function_exists($item['function'])) {
                     $ref = new ReflectionFunction($item['function']);
                     $file = $ref->getFileName();
                 } else {
                     if (isset($item['file'])) {
                         $file = $item['file'];
                     } else {
                         continue;
                     }
                 }
             }
             $comp = QM_Util::get_file_component($file);
             $components[$comp->type] = $comp;
         } catch (ReflectionException $e) {
             # nothing
         }
     }
     foreach (QM_Util::get_file_dirs() as $type => $dir) {
         if (isset($components[$type])) {
             return $components[$type];
         }
     }
     # This should not happen
 }