Ejemplo n.º 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;
 }
 /**
  * @Route /genbundle/export
  */
 public function exportAction()
 {
     $options = $this->app->getConfigurationLoader()->getBundlesLocation();
     if (isset($options[$this->app->request()->get('name')])) {
         $location = \Raptor\Core\Location::get(\Raptor\Core\Location::CACHE);
         if ($location . "/Installer") {
             @mkdir($location . "/Installer/created", 0777, true);
         }
         $file = rand(10, 100000);
         $zip = new \Raptor\Util\Zip($location . "/Installer/created/" . $file . ".zip");
         $zip->create($options[$this->app->request()->get('name')]);
         $this->app->response()->headers()->set('Content-Description', 'File Transfer');
         $this->app->response()->headers()->set('Content-Disposition', 'attachment; filename="' . $this->app->request()->get('name') . '.zip"');
         $this->app->contentType(\Raptor\Raptor::ZIP);
         $this->app->response()->headers()->set('Content-Transfer-Encoding', 'binary');
         $content = file_get_contents($location . "/Installer/created/" . $file . ".zip");
         @unlink($location . "/Installer/created/" . $file . ".zip");
         return $content;
     }
 }
Ejemplo n.º 3
0
 /**
  * Creating and Exporting a Zip
  * @Route /new/example/exportzip
  * 
  */
 public function exportZipAction()
 {
     $zip = new \Raptor\Util\Zip();
     /**
      * Give the directory or a file to compress
      * in this case will be the Controller directory
      * of this bundle 
      */
     $zip->create(__DIR__);
     $this->app->contentType(\Raptor\Raptor::ZIP);
     $this->app->response()->headers()->set('Content-Disposition', 'attachment; filename="testing.zip"');
     return $zip->output();
 }