/** * @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"; }
/** * 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)); }
/** * @Route /genbundle/checkexport */ public function checkExportAction() { $options = $this->app->getConfigurationLoader()->getBundlesLocation(); if (isset($options[$this->app->request()->post('name')])) { $install = \Raptor\Util\Files::find($options[$this->app->request()->post('name')], 'install.json'); if (count($install) > 0) { return $this->show("Please wait we are generating"); } else { return $this->show("The bundle that you want export hasn't an installer manifiest, please create one.", true, Controller::ERROR); } } return $this->show("We cannot find the bundle specified", true, Controller::ERROR); }
public static function checkingForInstall($name) { $file = \Raptor\Util\Files::find(self::prepareCache() . '/' . $name, 'install.json'); if (count($file) > 0) { return $file[0]; } return false; }
/** * @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)); }
/** * [USO INTERNO DEL SISTEMA] */ public function load() { foreach ($this->bundles as $bundle) { $class = new \Wingu\OctopusCore\Reflection\ReflectionClass($bundle); $prefix = ''; $this->location[$class->getShortName()] = \Raptor\Util\ClassLocation::getLocation($bundle); $this->specif[$class->getShortName()] = array('location' => \Raptor\Util\ClassLocation::getLocation($bundle), 'namespace' => $class->getNamespaceName(), 'name' => $class->getName()); if (!$class->getReflectionDocComment()->isEmpty() and $class->getReflectionDocComment()->getAnnotationsCollection()->hasAnnotationTag('Route')) { $doc = $class->getReflectionDocComment(); $obj = $doc->getAnnotationsCollection()->getAnnotation('Route'); $prefix = $obj[0]->getDescription(); } $controllerDir = \Raptor\Util\ClassLocation::getLocation($bundle) . '/Controller'; $listfiles = \Raptor\Util\Files::find($controllerDir, "*Controller.php"); foreach ($listfiles as $nombre_fichero) { $prefixController = $prefix; $namespaceSrc = explode('src', $nombre_fichero); $real = array(); if (count($namespaceSrc) > 1) { $real = $namespaceSrc[1]; } else { $namespaceSrc = explode('libs', $nombre_fichero); $real = $namespaceSrc[1]; } $namespaceClass = str_replace('.php', '', $real); $namespace = str_replace('/', '\\', $namespaceClass); $controller = new \Wingu\OctopusCore\Reflection\ReflectionClass($namespace); if (!$controller->getReflectionDocComment()->isEmpty() and $controller->getReflectionDocComment()->getAnnotationsCollection()->hasAnnotationTag('Route')) { $doc = $controller->getReflectionDocComment(); $obj = $doc->getAnnotationsCollection()->getAnnotation('Route'); $prefixController = $prefixController . $obj[0]->getDescription(); } foreach ($controller->getMethods() as $method) { /** * Searching the API in any method of controller classes */ $api = new \stdClass(); $api->hasApi = false; $api->version = '0.0.0'; $api->text = ''; $doc = $method->getReflectionDocComment(); if ($method->getReflectionDocComment()->getAnnotationsCollection()->hasAnnotationTag('api')) { $api->text = $method->getReflectionDocComment()->getFullDescription(); $collectionDescrip = $doc->getAnnotationsCollection()->getAnnotation('api'); $api->category = $collectionDescrip[0]->getDescription(); $api->class = $method->getDeclaringClass()->getName(); $api->bundle = $class->getName(); $api->method = $method->getName(); $api->hasApi = true; if ($method->getReflectionDocComment()->getAnnotationsCollection()->hasAnnotationTag('Route')) { $doc = $method->getReflectionDocComment(); $collectionRouteObj = $doc->getAnnotationsCollection()->getAnnotation('Route'); $collectionRoute = $collectionRouteObj[0]; $api->route = $prefixController . $collectionRoute->getDescription(); } else { $api->route = false; } if ($method->getReflectionDocComment()->getAnnotationsCollection()->hasAnnotationTag('version')) { $doc = $method->getReflectionDocComment(); $collectionRouteObj = $doc->getAnnotationsCollection()->getAnnotation('version'); $collectionRoute = $collectionRouteObj[0]; $api->version = $collectionRoute->getDescription(); } } if ($api->hasApi) { if (!isset($this->api[$api->category])) { $this->api[$api->category] = array(); } $this->api[$api->category][] = $api; } if (!$method->getReflectionDocComment()->isEmpty() and $method->getReflectionDocComment()->getAnnotationsCollection()->hasAnnotationTag('Route')) { if ($method->getReflectionDocComment()->getAnnotationsCollection()->hasAnnotationTag('RouteName')) { $collectionNameObj = $doc->getAnnotationsCollection()->getAnnotation('RouteName'); $collectionName = $collectionNameObj[0]->getDescription(); } else { $routeArray = $doc->getAnnotationsCollection()->getAnnotation('Route'); $Route = $routeArray[0]; $collectionName = str_replace('/', '_', $prefixController . $Route->getDescription()); } $collectionRouteObj = $doc->getAnnotationsCollection()->getAnnotation('Route'); $collectionRoute = $collectionRouteObj[0]; $descrip = ""; if ($method->getReflectionDocComment()->getAnnotationsCollection()->hasAnnotationTag('Description')) { $collectionDescrip = $doc->getAnnotationsCollection()->getAnnotation('Description'); $descrip = $collectionDescrip[0]->getDescription(); } $methodName = 'ANY'; if ($method->getReflectionDocComment()->getAnnotationsCollection()->hasAnnotationTag('Method')) { $collectionMethod = $doc->getAnnotationsCollection()->getAnnotation('Method'); $methodName = $collectionMethod[0]->getDescription(); } $this->definitions[$collectionName] = $api; $this->definitions[$collectionName] = array($prefixController . $collectionRoute->getDescription(), $method->getDeclaringClass()->getName(), $method->getName(), $class->getName(), 'method' => $methodName); $this->description[$prefixController . $collectionRoute->getDescription()] = array($descrip, $method->getReflectionDocComment()->getFullDescription()); } } } } }