Beispiel #1
0
 /**
  * Builds class schemata from classes annotated as entities or value objects
  *
  * @param string $className
  * @throws Exception\UnknownClassException
  * @return ClassSchema The class schema
  */
 protected function buildClassSchema($className)
 {
     if (!class_exists($className)) {
         throw new Exception\UnknownClassException('The classname "' . $className . '" was not found and thus can not be reflected.', 1278450972);
     }
     $classSchema = $this->objectManager->get(\TYPO3\CMS\Extbase\Reflection\ClassSchema::class, $className);
     if (is_subclass_of($className, \TYPO3\CMS\Extbase\DomainObject\AbstractEntity::class)) {
         $classSchema->setModelType(ClassSchema::MODELTYPE_ENTITY);
         $possibleRepositoryClassName = ClassNamingUtility::translateModelNameToRepositoryName($className);
         if (class_exists($possibleRepositoryClassName)) {
             $classSchema->setAggregateRoot(true);
         }
     } elseif (is_subclass_of($className, \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject::class)) {
         $classSchema->setModelType(ClassSchema::MODELTYPE_VALUEOBJECT);
     }
     foreach ($this->getClassPropertyNames($className) as $propertyName) {
         if (!$this->isPropertyTaggedWith($className, $propertyName, 'transient') && $this->isPropertyTaggedWith($className, $propertyName, 'var')) {
             $cascadeTagValues = $this->getPropertyTagValues($className, $propertyName, 'cascade');
             $classSchema->addProperty($propertyName, implode(' ', $this->getPropertyTagValues($className, $propertyName, 'var')), $this->isPropertyTaggedWith($className, $propertyName, 'lazy'), $cascadeTagValues[0]);
         }
         if ($this->isPropertyTaggedWith($className, $propertyName, 'uuid')) {
             $classSchema->setUuidPropertyName($propertyName);
         }
         if ($this->isPropertyTaggedWith($className, $propertyName, 'identity')) {
             $classSchema->markAsIdentityProperty($propertyName);
         }
     }
     $this->classSchemata[$className] = $classSchema;
     $this->dataCacheNeedsUpdate = true;
     return $classSchema;
 }
Beispiel #2
0
	/**
	 * @dataProvider repositoryAndModelClassNames
	 * @param string $expectedRepositoryName
	 * @param string $modelName
	 * @param string $dummyValidatorName not needed here - just a dummy to be able to cleanly use the same dataprovider
	 * @test
	 */
	public function translateModelNameToRepositoryName($expectedRepositoryName, $modelName, $dummyValidatorName) {
		$translatedRepositoryName = \TYPO3\CMS\Core\Utility\ClassNamingUtility::translateModelNameToRepositoryName($modelName);
		$this->assertSame($expectedRepositoryName, $translatedRepositoryName);
	}