public function testParseClassPathGetsNamespaceBundleAndEntity()
 {
     $classInfo = new SymfonyClassInfo();
     $classInfo->parseClassPath("SOA\\SOABundle\\Model\\ItemQuery");
     $this->assertEquals('SOA', $classInfo->namespace);
     $this->assertEquals('SOA', $classInfo->bundle);
     $this->assertEquals('Item', $classInfo->entity);
 }
 /**
  * This method will determine and return the resource route for the resource controller.
  *
  * @return string
  */
 public function getResourceRoute()
 {
     $docBlockUtility = new DocBlockUtility();
     $controllerClass = $this->controllerClassInfo->getClassPath('controller');
     $reflectionObject = new \ReflectionClass($controllerClass);
     $docBlock = $reflectionObject->getDocComment();
     $routeValue = $docBlockUtility->getAnnotationValue($docBlock, '@route');
     if ($routeValue === null) {
         throw new \Exception('Every resource controller must define a @route tag.');
     }
     return $routeValue;
 }
Exemplo n.º 3
0
 /**
  * This method will fix the namespaces for this data relation and any children relations.
  *
  * @param $query
  */
 public function correctNamespace($query)
 {
     // we need to make sure that our path information is populated correctly, which means
     // we need to traverse through the table maps
     $fullRelationPathParts = explode('.', $this->fullRelationPath);
     $currentTableMap = $query->getTableMap();
     foreach ($fullRelationPathParts as $nextStepRelation) {
         $nextLevelRelationMap = $currentTableMap->getRelation($nextStepRelation);
         $currentTableMap = $nextLevelRelationMap->getRightTable();
     }
     // we now have the table map of the table this join is pulling in. we can use that model class name
     // to get the correct symfony path information with the SymfonyClassInfo class
     $classInfo = new SymfonyClassInfo();
     $classInfo->parseClassPath($currentTableMap->getClassName());
     $this->namespace = $classInfo->namespace;
     $this->bundle = $classInfo->bundle;
     $this->entity = $classInfo->entity;
     if ($this->joinList) {
         foreach ($this->joinList as $childRelation) {
             $childRelation->correctNamespace($query);
         }
     }
 }