/** * Sets the object name of the controller * * @param string $controllerObjectName The fully qualified controller object name * @return void */ public function setControllerObjectName($controllerObjectName) { $nameParts = \TYPO3\CMS\Core\Utility\ClassNamingUtility::explodeObjectControllerName($controllerObjectName); $this->controllerExtensionName = $nameParts['extensionName']; $this->controllerObjectName = $controllerObjectName; $this->command = null; }
/** * This adds custom validators to the passed $conjunctionValidator. * * A custom validator is found if it follows the naming convention "Replace '\Model\' by '\Validator\' and * append 'Validator'". If found, it will be added to the $conjunctionValidator. * * In addition canValidate() will be called on all implementations of the ObjectValidatorInterface to find * all validators that could validate the target. The one with the highest priority will be added as well. * If multiple validators have the same priority, which one will be added is not deterministic. * * @param string $targetClassName * @param ConjunctionValidator $conjunctionValidator * @return NULL|Validator\ObjectValidatorInterface */ protected function addCustomValidators($targetClassName, ConjunctionValidator &$conjunctionValidator) { $addedValidatorClassName = NULL; // @todo: get rid of ClassNamingUtility usage once we dropped underscored class name support $possibleValidatorClassName = ClassNamingUtility::translateModelNameToValidatorName($targetClassName); $customValidator = $this->createValidator($possibleValidatorClassName); if ($customValidator !== NULL) { $conjunctionValidator->addValidator($customValidator); $addedValidatorClassName = get_class($customValidator); } // @todo: find polytype validator for class }
/** * 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; }
/** * Explicitly sets the object name of the controller * * @param string $controllerObjectName The fully qualified controller object name * * @return void */ public function setControllerObjectName($controllerObjectName) { $nameParts = ClassNamingUtility::explodeObjectControllerName($controllerObjectName); $this->controllerVendorName = isset($nameParts['vendorName']) ? $nameParts['vendorName'] : NULL; $this->controllerExtensionName = $nameParts['extensionName']; $this->controllerSubpackageKey = isset($nameParts['subpackageKey']) ? $nameParts['subpackageKey'] : NULL; $this->controllerName = $nameParts['controllerName']; }
/** * Constructs a new Repository * * @param \TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager */ public function __construct(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager) { $this->objectManager = $objectManager; $this->objectType = ClassNamingUtility::translateRepositoryNameToModelName($this->getRepositoryClassName()); }
/** * @dataProvider controllerObjectNamesAndMatches * * @param string $controllerObjectName * @param array $expectedMatches * @test */ public function explodeObjectControllerName($controllerObjectName, $expectedMatches) { $matches = \TYPO3\CMS\Core\Utility\ClassNamingUtility::explodeObjectControllerName($controllerObjectName); $actualMatches = array( 'vendorName' => $matches['vendorName'], 'extensionName' => $matches['extensionName'], 'subpackageKey' => $matches['subpackageKey'], 'controllerName' => $matches['controllerName'], ); $this->assertSame($expectedMatches, $actualMatches); }