/** * Adds properties of the class at hand to the class schema. * * Only non-transient properties annotated with a var annotation will be added. * Invalid annotations will cause an exception to be thrown. Properties pointing * to existing classes will only be added if the target type is annotated as * entity or valueobject. * * @param \TYPO3\FLOW3\Reflection\ClassSchema $classSchema * @return void * @throws \InvalidArgumentException * @throws \TYPO3\FLOW3\Reflection\Exception\InvalidPropertyTypeException */ protected function addPropertiesToClassSchema(\TYPO3\FLOW3\Reflection\ClassSchema $classSchema) { // those are added as property even if not tagged with entity/valueobject $propertyTypeWhiteList = array('DateTime', 'SplObjectStorage', 'Doctrine\\Common\\Collections\\Collection', 'Doctrine\\Common\\Collections\\ArrayCollection'); $className = $classSchema->getClassName(); $needsArtificialIdentity = TRUE; foreach ($this->getClassPropertyNames($className) as $propertyName) { if ($this->isPropertyTaggedWith($className, $propertyName, 'var') && !$this->isPropertyAnnotatedWith($className, $propertyName, 'TYPO3\\FLOW3\\Annotations\\Transient')) { $declaredType = trim(implode(' ', $this->getPropertyTagValues($className, $propertyName, 'var')), ' \\'); if (preg_match('/\\s/', $declaredType) === 1) { throw new \TYPO3\FLOW3\Reflection\Exception\InvalidPropertyTypeException('The @var annotation for "' . $className . '::$' . $propertyName . '" seems to be invalid.', 1284132314); } if ($this->isPropertyAnnotatedWith($className, $propertyName, 'Doctrine\\ORM\\Mapping\\Id')) { $needsArtificialIdentity = FALSE; } try { $parsedType = \TYPO3\FLOW3\Utility\TypeHandling::parseType($declaredType); } catch (\TYPO3\FLOW3\Utility\Exception\InvalidTypeException $exception) { throw new \InvalidArgumentException(sprintf($exception->getMessage(), 'class "' . $className . '" for property "' . $propertyName . '"'), 1315564475); } if (!in_array($parsedType['type'], $propertyTypeWhiteList) && (class_exists($parsedType['type']) || interface_exists($parsedType['type'])) && !($this->isClassAnnotatedWith($parsedType['type'], 'TYPO3\\FLOW3\\Annotations\\Entity') || $this->isClassAnnotatedWith($parsedType['type'], 'Doctrine\\ORM\\Mapping\\Entity') || $this->isClassAnnotatedWith($parsedType['type'], 'TYPO3\\FLOW3\\Annotations\\ValueObject'))) { continue; } $classSchema->addProperty($propertyName, $declaredType, $this->isPropertyAnnotatedWith($className, $propertyName, 'TYPO3\\FLOW3\\Annotations\\Lazy')); if ($this->isPropertyAnnotatedWith($className, $propertyName, 'TYPO3\\FLOW3\\Annotations\\Identity')) { $classSchema->markAsIdentityProperty($propertyName); } } } if ($needsArtificialIdentity === TRUE) { $classSchema->addProperty('FLOW3_Persistence_Identifier', 'string'); } }