115 protected $ignoredTags = array(
'package',
'subpackage',
'license',
'copyright',
'author',
'version',
'const');
173 if ($this->initialized) {
174 throw new \TYPO3\CMS\Extbase\Reflection\Exception(
'The Reflection Service can only be initialized once.', 1232044696);
176 $frameworkConfiguration = $this->configurationManager->getConfiguration(\
TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
177 $this->cacheIdentifier =
'ReflectionData_' . $frameworkConfiguration[
'extensionName'];
179 $this->initialized = TRUE;
197 if ($this->dataCacheNeedsUpdate) {
200 $this->initialized = FALSE;
210 if (!isset($this->reflectedClassNames[$className])) {
213 return isset($this->classPropertyNames[$className]) ? $this->classPropertyNames[$className] : array();
223 $className = is_object($classNameOrObject) ? get_class($classNameOrObject) : $classNameOrObject;
224 if (isset($this->classSchemata[$className])) {
225 return $this->classSchemata[$className];
241 if (!array_key_exists($className, $this->classMethodNames) || !array_key_exists($methodName, $this->classMethodNames[$className])) {
243 $this->classMethodNames[$className][$methodName] = TRUE;
245 }
catch (\ReflectionException $e) {
247 $this->classMethodNames[$className][$methodName] = NULL;
249 return isset($this->classMethodNames[$className][$methodName]);
260 if (!isset($this->methodTagsValues[$className][$methodName])) {
262 $this->methodTagsValues[$className][$methodName] = array();
263 foreach ($method->getTagsValues() as $tag => $values) {
264 if (array_search($tag, $this->ignoredTags) === FALSE) {
265 $this->methodTagsValues[$className][$methodName][$tag] = $values;
269 return $this->methodTagsValues[$className][$methodName];
281 if (!isset($this->methodParameters[$className][$methodName])) {
283 $this->methodParameters[$className][$methodName] = array();
284 foreach ($method->getParameters() as $parameterPosition => $parameter) {
288 return $this->methodParameters[$className][$methodName];
299 if (!isset($this->reflectedClassNames[$className])) {
302 if (!isset($this->propertyTagsValues[$className])) {
305 return isset($this->propertyTagsValues[$className][$propertyName]) ? $this->propertyTagsValues[$className][$propertyName] : array();
318 if (!isset($this->reflectedClassNames[$className])) {
321 if (!isset($this->propertyTagsValues[$className][$propertyName])) {
324 return isset($this->propertyTagsValues[$className][$propertyName][$tag]) ? $this->propertyTagsValues[$className][$propertyName][$tag] : array();
336 return isset($this->reflectedClassNames[$className]);
348 if ($this->initialized === FALSE) {
351 if (!isset($this->reflectedClassNames[$className])) {
354 if (!isset($this->classTagsValues[$className])) {
357 return isset($this->classTagsValues[$className][$tag]);
370 if (!isset($this->reflectedClassNames[$className])) {
373 if (!isset($this->propertyTagsValues[$className])) {
376 if (!isset($this->propertyTagsValues[$className][$propertyName])) {
379 return isset($this->propertyTagsValues[$className][$propertyName][$tag]);
389 $class = new \TYPO3\CMS\Extbase\Reflection\ClassReflection($className);
390 $this->reflectedClassNames[$className] = time();
391 foreach ($class->getTagsValues() as $tag => $values) {
392 if (array_search($tag, $this->ignoredTags) === FALSE) {
393 $this->taggedClasses[$tag][] = $className;
394 $this->classTagsValues[$className][$tag] = $values;
397 foreach ($class->getProperties() as $property) {
398 $propertyName = $property->getName();
399 $this->classPropertyNames[$className][] = $propertyName;
400 foreach ($property->getTagsValues() as $tag => $values) {
401 if (array_search($tag, $this->ignoredTags) === FALSE) {
402 $this->propertyTagsValues[$className][$propertyName][$tag] = $values;
406 foreach ($class->getMethods() as $method) {
407 $methodName = $method->getName();
408 foreach ($method->getTagsValues() as $tag => $values) {
409 if (array_search($tag, $this->ignoredTags) === FALSE) {
410 $this->methodTagsValues[$className][$methodName][$tag] = $values;
413 foreach ($method->getParameters() as $parameterPosition => $parameter) {
417 ksort($this->reflectedClassNames);
418 $this->dataCacheNeedsUpdate = TRUE;
429 if (!class_exists($className)) {
430 throw new \TYPO3\CMS\Extbase\Reflection\Exception\UnknownClassException(
'The classname "' . $className .
'" was not found and thus can not be reflected.', 1278450972);
432 $classSchema = $this->objectManager->get(
'TYPO3\\CMS\\Extbase\\Reflection\\ClassSchema', $className);
433 if (is_subclass_of($className,
'TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity')) {
436 if (class_exists($possibleRepositoryClassName)) {
437 $classSchema->setAggregateRoot(TRUE);
439 } elseif (is_subclass_of($className,
'TYPO3\\CMS\\Extbase\\DomainObject\\AbstractValueObject')) {
445 $classSchema->addProperty($propertyName, implode(
' ', $this->
getPropertyTagValues($className, $propertyName,
'var')), $this->
isPropertyTaggedWith($className, $propertyName,
'lazy'), $cascadeTagValues[0]);
448 $classSchema->setUuidPropertyName($propertyName);
451 $classSchema->markAsIdentityProperty($propertyName);
454 $this->classSchemata[$className] = $classSchema;
455 $this->dataCacheNeedsUpdate = TRUE;
468 $parameterInformation = array(
469 'position' => $parameterPosition,
470 'byReference' => $parameter->isPassedByReference(),
471 'array' => $parameter->isArray(),
472 'optional' => $parameter->isOptional(),
473 'allowsNull' => $parameter->allowsNull()
475 $parameterClass = $parameter->getClass();
476 $parameterInformation[
'class'] = $parameterClass !== NULL ? $parameterClass->getName() : NULL;
477 if ($parameter->isDefaultValueAvailable()) {
478 $parameterInformation[
'defaultValue'] = $parameter->getDefaultValue();
480 if ($parameterClass !== NULL) {
481 $parameterInformation[
'type'] = $parameterClass->getName();
482 } elseif ($method !== NULL) {
483 $methodTagsAndValues = $this->
getMethodTagsValues($method->getDeclaringClass()->getName(), $method->getName());
484 if (isset($methodTagsAndValues[
'param']) && isset($methodTagsAndValues[
'param'][$parameterPosition])) {
485 $explodedParameters = explode(
' ', $methodTagsAndValues[
'param'][$parameterPosition]);
486 if (count($explodedParameters) >= 2) {
487 $parameterInformation[
'type'] = $explodedParameters[0];
491 if (isset($parameterInformation[
'type']) && $parameterInformation[
'type'][0] ===
'\\') {
492 $parameterInformation[
'type'] = substr($parameterInformation[
'type'], 1);
494 return $parameterInformation;
505 $this->dataCacheNeedsUpdate = TRUE;
506 if (!isset($this->methodReflections[$className][$methodName])) {
507 $this->methodReflections[$className][$methodName] = new \TYPO3\CMS\Extbase\Reflection\MethodReflection($className, $methodName);
509 return $this->methodReflections[$className][$methodName];
518 $data = $this->dataCache->get($this->cacheIdentifier);
519 if ($data !== FALSE) {
520 foreach ($data as $propertyName => $propertyValue) {
521 $this->{$propertyName} = $propertyValue;
533 if (!is_object($this->dataCache)) {
534 throw new \TYPO3\CMS\Extbase\Reflection\Exception(
'A cache must be injected before initializing the Reflection Service.', 1232044697);
537 $propertyNames = array(
538 'reflectedClassNames',
539 'classPropertyNames',
544 'propertyTagsValues',
548 foreach ($propertyNames as $propertyName) {
549 $data[$propertyName] = $this->{$propertyName};
551 $this->dataCache->set($this->cacheIdentifier, $data);
552 $this->dataCacheNeedsUpdate = FALSE;
static translateModelNameToRepositoryName($modelName)
isClassReflected($className)
getClassPropertyNames($className)
getPropertyTagValues($className, $propertyName, $tag)
getMethodParameters($className, $methodName)
setDataCache(\TYPO3\CMS\Core\Cache\Frontend\VariableFrontend $dataCache)
getPropertyTagsValues($className, $propertyName)
const MODELTYPE_VALUEOBJECT
getMethodReflection($className, $methodName)
isPropertyTaggedWith($className, $propertyName, $tag)
getMethodTagsValues($className, $methodName)
getClassSchema($classNameOrObject)
convertParameterReflectionToArray(\ReflectionParameter $parameter, $parameterPosition, \ReflectionMethod $method=NULL)
hasMethod($className, $methodName)
buildClassSchema($className)
isClassTaggedWith($className, $tag)