/**
  * @Route /cleanajax
  * @RouteName _raptor_clean_ajax
  */
 public function cleanAjaxAction()
 {
     $cache = \Raptor\Core\Location::get(\Raptor\Core\Location::CACHE);
     \Raptor\Util\Files::delete($cache . '/7u136');
     $this->app->getConfigurationLoader()->forceLoad();
     return "OK";
 }
 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 /resources/publisher/clear
  */
 public function clearAction($request)
 {
     $bundleName = $request->post('bundles');
     $bundleName = json_decode($bundleName);
     $bundles = $this->app->getConfigurationLoader()->getBundlesSpecifications();
     $web = \Raptor\Core\Location::get(\Raptor\Core\Location::WEBBUNDLES);
     $console = array();
     foreach ($bundleName as $value) {
         if (isset($bundles[$value])) {
             $fileBundle = str_replace('Bundle', '', $bundles[$value]['namespace']);
             $fileBundle = str_replace('\\', '/', $fileBundle);
             \Raptor\Util\Files::delete($web . '/' . $fileBundle);
             $console[] = "The resources {$value} are deleted";
             if (count(glob($web . '/' . $fileBundle . '/../*')) == 0) {
                 rmdir($web . '/' . $fileBundle . '/..');
             }
         }
     }
     return $this->show('The resources was deleted', true, \Raptor\Bundle\Controller\Controller::INFO, array('actions' => $console));
 }