Beispiel #1
0
 public static function proccesBundle($bundle)
 {
     $zip = new \Raptor\Util\Zip($bundle);
     $rand_id = rand(10, 100000);
     $name_rand = 'id_install_' . $rand_id;
     $zip->extract(self::prepareCache() . '/' . $name_rand);
     $src = \Raptor\Core\Location::get(\Raptor\Core\Location::SRC);
     @unlink($bundle);
     $result = self::checkingForInstall($name_rand);
     if ($result !== false) {
         $meta = json_decode(utf8_encode(file_get_contents($result)), true);
         if (isset($meta['namespace'])) {
             $parts = explode('.', $meta['namespace']);
             if (!file_exists($src . '/' . $parts[0] . '/' . $parts[1])) {
                 if (!file_exists($src . '/' . $parts[0])) {
                     @mkdir(self::prepareCache() . '/' . $parts[0]);
                 }
                 $match = \Raptor\Util\Files::find(self::prepareCache() . '/' . $name_rand, $parts[1]);
                 if (count($match) > 0) {
                     \Raptor\Util\Files::copy($match[0], $src . '/' . $parts[0] . '/' . $parts[1]);
                     $error = 'The installer finish to import and run the bundle !!<br>';
                     if (isset($meta['installScript']) and file_exists($src . '/' . $parts[0] . '/' . $parts[1] . '/' . $meta['installScript'])) {
                         $message = (require $src . '/' . $parts[0] . '/' . $parts[1] . '/' . $meta['installScript']);
                         $error .= is_string($message) ? $message : '';
                     }
                     \Raptor\Raptor::getInstance()->getConfigurationLoader()->forceLoad();
                 } else {
                     //Show error
                     $error = '<span style="color:red">Cannot find the bundle especified in the manifiest</span>';
                 }
             } else {
                 //Show error
                 $error = '<span style="color:red">The bundle especified already exist or an existent bundle have the same name</span>';
             }
         } else {
             //Show error
             $error = '<span style="color:red">The Namepace param is a critical parameter in the manifiest and is missing</span>';
         }
     } else {
         //Show error
         $error = '<span style="color:red">We cannot find an installer manifiest in the zip bundle</span>';
     }
     $hidden = \Raptor\Util\Files::find(self::prepareCache() . '/' . $name_rand, '.*');
     foreach ($hidden as $value) {
         @unlink($value);
     }
     \Raptor\Util\Files::delete(self::prepareCache() . '/' . $name_rand);
     return $error;
 }