コード例 #1
0
ファイル: Resources.php プロジェクト: williamamed/Raptor2
 /**
  * Establece el bundle donde se creara el archivo especificado en setAsset
  * 
  * [USADO POR RAPTOR]
  * @param string $bundle
  */
 public function setBundle($bundle)
 {
     $location = ClassLocation::getLocation($bundle);
     $this->bundleRoute = $location . DIRECTORY_SEPARATOR . 'Resources';
 }
コード例 #2
0
ファイル: Language.php プロジェクト: williamamed/Raptor2
 /**
  * 
  * Devuelve la definicion de lenguaje para el bundle y lenguaje actual
  * Sera devuelta la definicion completa del archivo, ejemplo. la definicion de es.json
  * @return string
  */
 public function getBundleFile()
 {
     if (!$this->current_bundle) {
         return "{}";
     }
     $location = \Raptor\Util\ClassLocation::getLocation($this->current_bundle);
     $route = $location . "";
     $ultimate_session = \Raptor\Raptor::getInstance()->getSession()->get('rpt_lang');
     $lan = '';
     if ($ultimate_session) {
         $lan = $ultimate_session;
     } else {
         $lan = $this->getSystemLanguage();
     }
     if (file_exists($route . '/Translation/' . $lan . '.json')) {
         $file = file_get_contents($route . '/Translation/' . $lan . '.json');
     } else {
         $file = '{}';
     }
     return $file;
 }
コード例 #3
0
ファイル: Reader.php プロジェクト: williamamed/Raptor2
 /**
  * [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());
                 }
             }
         }
     }
 }