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; }
/** * Los archivos copiados seran aquellos contenidos en el directrorio Resources del bundle * * @param string $bundle El bundle que se copiara los recursos * @param boolean $extPreCompile Si este parametro es true, se ejecutaram ademas una rutina de busqueda dentro de los recursos para la compilacion de recursos Extjs */ public static function run($bundle, $extPreCompile = false) { $class = new \Wingu\OctopusCore\Reflection\ReflectionClass($bundle); $location = dirname($class->getFileName()); if (file_exists($location . DIRECTORY_SEPARATOR . 'Resources')) { $fileBundle = str_replace('Bundle', '', $class->getNamespaceName()); $fileBundle = str_replace('\\', '/', $fileBundle); $web = \Raptor\Core\Location::get(\Raptor\Core\Location::WEBBUNDLES); if (!file_exists($web . '/' . $fileBundle)) { mkdir($web . '/' . $fileBundle, 0777, true); } \Raptor\Util\Files::copy($location . DIRECTORY_SEPARATOR . 'Resources', $web . '/' . $fileBundle); if ($extPreCompile) { Extjs::preCompileApp($web . '/' . $fileBundle); } } }
/** * * * @Route /bundle/installer/module * * * @param \Slim\Http\Request $request * @param \Slim\Http\Response $response * @param \Slim\Route $route */ public function bundleInstallerModuleAction($request) { $msg = ""; if ($request->get('name') and $request->get('type') == 'local') { $dir = \Raptor2\InstallerBundle\Importer\BundleImporter::prepareCache(); $meta = \Raptor2\InstallerBundle\Importer\BundleImporter::getMetainformation($request->get('name')); if ($meta !== false) { \Raptor\Util\Files::copy(__DIR__ . '/../BundleStorage/files/' . $meta['file'], $dir); $msg = \Raptor2\InstallerBundle\Importer\BundleImporter::proccesBundle($dir . '/' . $meta['file']); } } elseif ($request->get('name') and $request->get('type') == 'remote' and $request->get('url')) { $file = \Raptor2\InstallerBundle\Importer\BundleImporter::downloadRemoteFile($request->get('url')); $msg = \Raptor2\InstallerBundle\Importer\BundleImporter::proccesBundle($file); } $local = \Raptor2\InstallerBundle\Importer\BundleImporter::getMetainformation(); $conf = $this->getApp()->getConfigurationLoader()->getConfOption(); if (isset($conf['raptor']['repository'])) { $remote = \Raptor2\InstallerBundle\Importer\BundleImporter::getRemoteMetainformation($conf['raptor']['repository']); $local = array_merge($local, $remote); } return $this->render('@InstallerBundle/installer/index.html.twig', array('modules' => $local, 'message' => $msg)); }