getClassNameByObjectName() public method

Returns the implementation class name for the specified object
public getClassNameByObjectName ( string $objectName ) : string
$objectName string The object name
return string The class name corresponding to the given object name or FALSE if no such object is registered
 /**
  * Matches a \Neos\Flow\Mvc\RequestInterface against the configured CSRF pattern rules and
  * searches for invalid csrf tokens. If this returns TRUE, the request is invalid!
  *
  * @param RequestInterface $request The request that should be matched
  * @return boolean TRUE if the pattern matched, FALSE otherwise
  * @throws AuthenticationRequiredException
  */
 public function matchRequest(RequestInterface $request)
 {
     if (!$request instanceof ActionRequest || $request->getHttpRequest()->isMethodSafe()) {
         $this->systemLogger->log('CSRF: No token required, safe request', LOG_DEBUG);
         return false;
     }
     if ($this->authenticationManager->isAuthenticated() === false) {
         $this->systemLogger->log('CSRF: No token required, not authenticated', LOG_DEBUG);
         return false;
     }
     if ($this->securityContext->areAuthorizationChecksDisabled() === true) {
         $this->systemLogger->log('CSRF: No token required, authorization checks are disabled', LOG_DEBUG);
         return false;
     }
     $controllerClassName = $this->objectManager->getClassNameByObjectName($request->getControllerObjectName());
     $actionMethodName = $request->getControllerActionName() . 'Action';
     if (!$this->hasPolicyEntryForMethod($controllerClassName, $actionMethodName)) {
         $this->systemLogger->log(sprintf('CSRF: No token required, method %s::%s() is not restricted by a policy.', $controllerClassName, $actionMethodName), LOG_DEBUG);
         return false;
     }
     if ($this->reflectionService->isMethodTaggedWith($controllerClassName, $actionMethodName, 'skipcsrfprotection')) {
         $this->systemLogger->log(sprintf('CSRF: No token required, method %s::%s() is tagged with a "skipcsrfprotection" annotation', $controllerClassName, $actionMethodName), LOG_DEBUG);
         return false;
     }
     $httpRequest = $request->getHttpRequest();
     if ($httpRequest->hasHeader('X-Flow-Csrftoken')) {
         $csrfToken = $httpRequest->getHeader('X-Flow-Csrftoken');
     } else {
         $internalArguments = $request->getMainRequest()->getInternalArguments();
         $csrfToken = isset($internalArguments['__csrfToken']) ? $internalArguments['__csrfToken'] : null;
     }
     if (empty($csrfToken)) {
         $this->systemLogger->log(sprintf('CSRF: token was empty but a valid token is required for %s::%s()', $controllerClassName, $actionMethodName), LOG_DEBUG);
         return true;
     }
     if (!$this->securityContext->hasCsrfProtectionTokens()) {
         throw new AuthenticationRequiredException(sprintf('CSRF: No CSRF tokens in security context, possible session timeout. A valid token is required for %s::%s()', $controllerClassName, $actionMethodName), 1317309673);
     }
     if ($this->securityContext->isCsrfProtectionTokenValid($csrfToken) === false) {
         $this->systemLogger->log(sprintf('CSRF: token was invalid but a valid token is required for %s::%s()', $controllerClassName, $actionMethodName), LOG_DEBUG);
         return true;
     }
     $this->systemLogger->log(sprintf('CSRF: Successfully verified token for %s::%s()', $controllerClassName, $actionMethodName), LOG_DEBUG);
     return false;
 }
 /**
  * Creates a node from the given NodeData container.
  *
  * If this factory has previously created a Node for the given $node and it's dimensions,
  * it will return the same node again.
  *
  * @param NodeData $nodeData
  * @param Context $context
  * @return NodeInterface
  * @throws NodeConfigurationException if a configured 'class' for a Node does not exist or does not inherit NodeInterface
  */
 public function createFromNodeData(NodeData $nodeData, Context $context)
 {
     if ($nodeData->isInternal()) {
         return null;
     }
     $internalNodeIdentifier = $nodeData->getIdentifier() . spl_object_hash($context);
     // In case there is a Node with an internal NodeData (because the NodeData was changed in the meantime) we need to flush it.
     if (isset($this->nodes[$internalNodeIdentifier]) && $this->nodes[$internalNodeIdentifier]->getNodeData()->isInternal()) {
         unset($this->nodes[$internalNodeIdentifier]);
     }
     if (!isset($this->nodes[$internalNodeIdentifier])) {
         // Warning: Alternative node implementations are considered internal for now, feature can change or be removed anytime. We want to be sure it works well and makes sense before declaring it public.
         $class = $nodeData->getNodeType()->getConfiguration('class') ?: $this->objectManager->getClassNameByObjectName(NodeInterface::class);
         if (!in_array($class, static::getNodeInterfaceImplementations($this->objectManager))) {
             throw new NodeConfigurationException('The configured implementation class name "' . $class . '" for NodeType "' . $nodeData->getNodeType() . '" does not inherit from ' . NodeInterface::class . '.', 1406884014);
         }
         $this->nodes[$internalNodeIdentifier] = new $class($nodeData, $context);
     }
     $node = $this->nodes[$internalNodeIdentifier];
     return $this->filterNodeByContext($node, $context);
 }
 /**
  * Returns the name of the action the controller is supposed to execute.
  *
  * @return string Action name
  * @api
  */
 public function getControllerActionName()
 {
     $controllerObjectName = $this->getControllerObjectName();
     if ($controllerObjectName !== '' && $this->controllerActionName === strtolower($this->controllerActionName)) {
         $controllerClassName = $this->objectManager->getClassNameByObjectName($controllerObjectName);
         $lowercaseActionMethodName = strtolower($this->controllerActionName) . 'action';
         foreach (get_class_methods($controllerClassName) as $existingMethodName) {
             if (strtolower($existingMethodName) === $lowercaseActionMethodName) {
                 $this->controllerActionName = substr($existingMethodName, 0, -6);
                 break;
             }
         }
     }
     return $this->controllerActionName;
 }
 /**
  * Reconstitutes an object from a serialized object without calling the constructor.
  *
  * @param string $objectHash Identifier of the serialized object
  * @param array $objectData The object data array
  * @return object
  */
 protected function reconstituteObject($objectHash, array $objectData)
 {
     if (isset($this->reconstitutedObjects[$objectHash])) {
         return $this->reconstitutedObjects[$objectHash];
     }
     $className = $this->objectManager->getClassNameByObjectName($objectData[self::CLASSNAME]);
     $object = unserialize('O:' . strlen($className) . ':"' . $className . '":0:{};');
     $this->reconstitutedObjects[$objectHash] = $object;
     foreach ($objectData[self::PROPERTIES] as $propertyName => $propertyData) {
         switch ($propertyData[self::TYPE]) {
             case 'simple':
                 $propertyValue = $propertyData[self::VALUE];
                 break;
             case 'array':
                 $propertyValue = $this->reconstituteArray($propertyData[self::VALUE]);
                 break;
             case 'Collection':
                 $propertyValue = $this->reconstituteCollection($propertyData[self::CLASSNAME], $propertyData[self::VALUE]);
                 break;
             case 'ArrayObject':
                 $propertyValue = new \ArrayObject($this->reconstituteArray($propertyData[self::VALUE]));
                 break;
             case 'object':
                 $propertyValue = $this->reconstituteObject($propertyData[self::VALUE], $this->objectsAsArray[$propertyData[self::VALUE]]);
                 break;
             case 'SplObjectStorage':
                 $propertyValue = $this->reconstituteSplObjectStorage($propertyData[self::VALUE]);
                 break;
             case 'persistenceObject':
                 list($propertyClassName, $propertyUuid) = explode(':', $propertyData[self::VALUE]);
                 $propertyValue = $this->reconstitutePersistenceObject($propertyClassName, $propertyUuid);
                 break;
         }
         $reflectionProperty = new \ReflectionProperty(get_class($object), $propertyName);
         $reflectionProperty->setAccessible(true);
         $reflectionProperty->setValue($object, $propertyValue);
     }
     return $object;
 }
 /**
  * Dispatches a signal by calling the registered Slot methods
  *
  * @param string $signalClassName Name of the class containing the signal
  * @param string $signalName Name of the signal
  * @param array $signalArguments arguments passed to the signal method
  * @return void
  * @throws Exception\InvalidSlotException if the slot is not valid
  * @api
  */
 public function dispatch($signalClassName, $signalName, array $signalArguments = [])
 {
     if (!isset($this->slots[$signalClassName][$signalName])) {
         return;
     }
     foreach ($this->slots[$signalClassName][$signalName] as $slotInformation) {
         if (isset($slotInformation['object'])) {
             $object = $slotInformation['object'];
         } elseif (substr($slotInformation['method'], 0, 2) === '::') {
             if (!isset($this->objectManager)) {
                 if (is_callable($slotInformation['class'] . $slotInformation['method'])) {
                     $object = $slotInformation['class'];
                 } else {
                     throw new Exception\InvalidSlotException(sprintf('Cannot dispatch %s::%s to class %s. The object manager is not yet available in the Signal Slot Dispatcher and therefore it cannot dispatch classes.', $signalClassName, $signalName, $slotInformation['class']), 1298113624);
                 }
             } else {
                 $object = $this->objectManager->getClassNameByObjectName($slotInformation['class']);
             }
             $slotInformation['method'] = substr($slotInformation['method'], 2);
         } else {
             if (!isset($this->objectManager)) {
                 throw new Exception\InvalidSlotException(sprintf('Cannot dispatch %s::%s to class %s. The object manager is not yet available in the Signal Slot Dispatcher and therefore it cannot dispatch classes.', $signalClassName, $signalName, $slotInformation['class']), 1298113624);
             }
             if (!$this->objectManager->isRegistered($slotInformation['class'])) {
                 throw new Exception\InvalidSlotException('The given class "' . $slotInformation['class'] . '" is not a registered object.', 1245673367);
             }
             $object = $this->objectManager->get($slotInformation['class']);
         }
         if ($slotInformation['passSignalInformation'] === true) {
             $signalArguments[] = $signalClassName . '::' . $signalName;
         }
         if (!method_exists($object, $slotInformation['method'])) {
             throw new Exception\InvalidSlotException('The slot method ' . get_class($object) . '->' . $slotInformation['method'] . '() does not exist.', 1245673368);
         }
         call_user_func_array([$object, $slotInformation['method']], $signalArguments);
     }
 }
 /**
  * Builds a new instance of $objectType with the given $possibleConstructorArgumentValues.
  * If constructor argument values are missing from the given array the method looks for a
  * default value in the constructor signature.
  *
  * Furthermore, the constructor arguments are removed from $possibleConstructorArgumentValues
  *
  * @param array &$possibleConstructorArgumentValues
  * @param string $objectType
  * @return object The created instance
  * @throws InvalidTargetException if a required constructor argument is missing
  */
 protected function buildObject(array &$possibleConstructorArgumentValues, $objectType)
 {
     $constructorArguments = [];
     $className = $this->objectManager->getClassNameByObjectName($objectType);
     $constructorSignature = $this->getConstructorArgumentsForClass($className);
     if (count($constructorSignature)) {
         foreach ($constructorSignature as $constructorArgumentName => $constructorArgumentReflection) {
             if (array_key_exists($constructorArgumentName, $possibleConstructorArgumentValues)) {
                 $constructorArguments[] = $possibleConstructorArgumentValues[$constructorArgumentName];
                 unset($possibleConstructorArgumentValues[$constructorArgumentName]);
             } elseif ($constructorArgumentReflection['optional'] === true) {
                 $constructorArguments[] = $constructorArgumentReflection['defaultValue'];
             } elseif ($this->objectManager->isRegistered($constructorArgumentReflection['type']) && $this->objectManager->getScope($constructorArgumentReflection['type']) === Configuration::SCOPE_SINGLETON) {
                 $constructorArguments[] = $this->objectManager->get($constructorArgumentReflection['type']);
             } else {
                 throw new InvalidTargetException('Missing constructor argument "' . $constructorArgumentName . '" for object of type "' . $objectType . '".', 1268734872);
             }
         }
         $classReflection = new \ReflectionClass($className);
         return $classReflection->newInstanceArgs($constructorArguments);
     } else {
         return new $className();
     }
 }