コード例 #1
0
ファイル: RestClass.php プロジェクト: softfly/GeneratorBundle
 private function getRestDirHelper(EntityClass $entitlyClass)
 {
     $namespace = $entitlyClass->getClassMetadata()->namespace;
     if (preg_match('/entity/i', $namespace)) {
         $restDir = str_ireplace('entity', 'Controller\\Rest', $namespace);
     } else {
         $a = explode('\\', $namespace);
         $b = array_merge(array_slice($a, 0, 1), array('Controller', 'Rest'), array_slice($a, 2));
         $restDir = implode('\\', $b);
     }
     return $restDir;
 }
コード例 #2
0
 private function getAssociationMappings(EntityClass $entityWrapper, $ignore = null)
 {
     if ($this->depth >= $this->max_depth) {
         return array();
     } else {
         $this->depth++;
         $mappings = array();
         foreach ($entityWrapper->getClassMetadata()->getAssociationMappings() as $column) {
             if ($ignore != $column['fieldName']) {
                 $mappingModel = new AssociationMappingModel();
                 $entityWrapper2 = new EntityClass($column['targetEntity'], $this->getEm());
                 $mappingModel->setSingularName(lcfirst($entityWrapper2->getSingluarName()));
                 $mappingModel->setFullName('\\' . $entityWrapper2->getFullName());
                 $mappingModel->setGetMethod('get' . ucfirst($this->camelize($column['fieldName'])));
                 $mappingModel->setMapType($column['type']);
                 $mappingModel->setDepth($this->depth);
                 $mappingModel->setColumns($this->getColumns($entityWrapper2, $column['mappedBy']));
                 $mappingModel->setMapping($this->getAssociationMappings($entityWrapper2, $column['mappedBy']));
                 $mappings[] = $mappingModel;
             }
         }
         $this->depth--;
         return $mappings;
     }
 }