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 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); } } }