示例#1
0
 /**
  * Builds class schemata from classes annotated as entities or value objects
  *
  * @param array $classNames
  * @return void
  */
 protected function buildClassSchemata(array $classNames)
 {
     foreach ($classNames as $className) {
         $classSchema = new \TYPO3\FLOW3\Reflection\ClassSchema($className);
         if ($this->isClassAnnotatedWith($className, 'TYPO3\\FLOW3\\Annotations\\Entity') || $this->isClassAnnotatedWith($className, 'Doctrine\\ORM\\Mapping\\Entity')) {
             $classSchema->setModelType(\TYPO3\FLOW3\Reflection\ClassSchema::MODELTYPE_ENTITY);
             $classSchema->setLazyLoadableObject($this->isClassAnnotatedWith($className, 'TYPO3\\FLOW3\\Annotations\\Lazy'));
             $possibleRepositoryClassName = str_replace('\\Model\\', '\\Repository\\', $className) . 'Repository';
             if ($this->isClassReflected($possibleRepositoryClassName) === TRUE) {
                 $classSchema->setRepositoryClassName($possibleRepositoryClassName);
             }
         } elseif ($this->isClassAnnotatedWith($className, 'TYPO3\\FLOW3\\Annotations\\ValueObject')) {
             $this->checkValueObjectRequirements($className);
             $classSchema->setModelType(\TYPO3\FLOW3\Reflection\ClassSchema::MODELTYPE_VALUEOBJECT);
         }
         $this->addPropertiesToClassSchema($classSchema);
         $this->classSchemata[$className] = $classSchema;
     }
     $this->completeRepositoryAssignments();
     $this->ensureAggregateRootInheritanceChainConsistency();
 }
示例#2
0
 /**
  * @test
  */
 public function setModelTypeResetsIdentityPropertiesAndAggregateRootForValueObjects()
 {
     $classSchema = new \TYPO3\FLOW3\Reflection\ClassSchema('SomeClass');
     $classSchema->setModelType(\TYPO3\FLOW3\Reflection\ClassSchema::MODELTYPE_ENTITY);
     $classSchema->addProperty('foo', 'string');
     $classSchema->addProperty('bar', 'string');
     $classSchema->markAsIdentityProperty('bar');
     $classSchema->setRepositoryClassName('Some\\Repository');
     $this->assertSame(array('bar' => 'string'), $classSchema->getIdentityProperties());
     $classSchema->setModelType(\TYPO3\FLOW3\Reflection\ClassSchema::MODELTYPE_VALUEOBJECT);
     $this->assertSame(array(), $classSchema->getIdentityProperties());
     $this->assertFalse($classSchema->isAggregateRoot());
 }