function uses_make()
 {
     $meta = new so_Tree();
     $meta->string = $this->file->content;
     $depends = array();
     foreach ($meta->get('include pack') as $packageId) {
         $package = $this->root[trim($packageId)];
         if (!$package->exists) {
             throw new \Exception("Pack [{$package->dir}] not found for [{$this->file}]");
         }
         $depends += $package->modules->list;
     }
     foreach ($meta->get('include module') as $moduleId) {
         $names = explode('/', trim($moduleId));
         if (!isset($names[1])) {
             array_push($names, $this->package->name);
         }
         $module = $this->root[$names[0]][$names[1]];
         if (!$module->exists) {
             throw new \Exception("Module [{$module->dir}] not found for [{$this->file}]");
         }
         $depends += $module->modules->list;
     }
     return so_module_collection::make($depends);
 }
Beispiel #2
0
 function get_dependModules($depends)
 {
     if (isset($depends)) {
         return $depends;
     }
     $depends = array();
     if ($this->ext === 'jam.js') {
         preg_match_all('/(?:\\$(\\w+)\\.)(\\w+)(?![\\w$])/', $this->content, &$matches, PREG_SET_ORDER);
         if ($matches) {
             foreach ($matches as $item) {
                 list($str, $packName, $moduleName) = $item;
                 $pack = $this->root->createPack($packName);
                 if (!$pack->exists) {
                     throw new Exception("Pack [{$pack->id}] not found for [{$this->id}]");
                 }
                 $module = $pack->createModule($moduleName);
                 if (!$module->exists) {
                     throw new Exception("Module [{$module->id}] not found for [{$this->id}]");
                 }
                 $depends[$module->id] = $module;
                 $module = $module->pack->mainModule;
                 if ($module->exists) {
                     $depends[$module->id] = $module;
                 }
             }
         }
     }
     if ($this->ext === 'php') {
         preg_match_all('/class\\s+\\w+\\s+extends\\s+([a-zA-Z]+)_([a-zA-Z]+)/', $this->content, &$matches1, PREG_SET_ORDER);
         preg_match_all('/\\b([a-zA-Z]+)_([a-zA-Z]+)\\w*::/', $this->content, &$matches2, PREG_SET_ORDER);
         $matches = array_merge($matches1, $matches2);
         if ($matches) {
             foreach ($matches as $item) {
                 list($str, $packName, $moduleName) = $item;
                 $pack = $this->root->createPack($packName);
                 $module = $pack->createModule($moduleName);
                 if (!$module || !$module->exists) {
                     throw new Exception("Module [{$module->id}] not found for [{$this->id}]");
                 }
                 $depends[$module->id] = $module;
                 $module = $module->pack->mainModule;
                 if ($module->exists) {
                     $depends[$module->id] = $module;
                 }
             }
         }
     }
     if ($this->ext === 'xsl') {
         preg_match_all('/<([a-zA-Z]+):([a-zA-Z-]+)/', $this->content, &$matches1, PREG_SET_ORDER);
         preg_match_all('/\\b([a-zA-Z]+):([a-zA-Z-]+)=[\'"]/', $this->content, &$matches2, PREG_SET_ORDER);
         $matches = array_merge($matches1, $matches2);
         if ($matches) {
             foreach ($matches as $item) {
                 list($str, $packName, $moduleName) = $item;
                 if ($packName == 'xsl') {
                     continue;
                 }
                 if ($packName == 'xmlns') {
                     continue;
                 }
                 if ($packName == 'xml') {
                     continue;
                 }
                 $pack = $this->root->createPack($packName);
                 $module = $pack->createModule($moduleName);
                 if (!$module || !$module->exists) {
                     throw new Exception("Module [{$module->id}] not found for [{$this->id}]");
                 }
                 $depends[$module->id] = $module;
                 $module = $module->pack->mainModule;
                 if ($module->exists) {
                     $depends[$module->id] = $module;
                 }
             }
         }
     }
     if ($this->ext === 'meta.tree') {
         $meta = new so_Tree();
         $meta->string = $this->content;
         foreach ($meta->get('include pack') as $packId) {
             $pack = $this->root->createPack(trim($packId));
             if (!$pack->exists) {
                 throw new Exception("Pack [{$pack->id}] not found for [{$this->id}]");
             }
             $depends += $pack->modules;
         }
         foreach ($meta->get('include module') as $moduleId) {
             $names = explode('/', trim($moduleId));
             if (!$names[1]) {
                 array_push($names, $this->pack->name);
             }
             $pack = $this->root->createPack($names[0]);
             $module = $pack->createModule($names[1]);
             if (!$module->exists) {
                 throw new Exception("Module [{$module->id}] not found for [{$this->id}]");
             }
             $depends[$module->id] = $module;
         }
     }
     return $depends;
 }