isRegistered() публичный Метод

Returns TRUE if an object with the given name has already been registered.
С версии: 1.0.0 alpha 8
public isRegistered ( string $objectName ) : boolean
$objectName string Name of the object
Результат boolean TRUE if the object has been registered, otherwise FALSE
Пример #1
0
 /**
  * Handle an Exception thrown while rendering TypoScript according to
  * settings specified in Neos.Fusion.rendering.exceptionHandler
  *
  * @param array $typoScriptPath
  * @param \Exception $exception
  * @param boolean $useInnerExceptionHandler
  * @return string
  * @throws InvalidConfigurationException
  */
 public function handleRenderingException($typoScriptPath, \Exception $exception, $useInnerExceptionHandler = false)
 {
     $typoScriptConfiguration = $this->getConfigurationForPath($typoScriptPath);
     if (isset($typoScriptConfiguration['__meta']['exceptionHandler'])) {
         $exceptionHandlerClass = $typoScriptConfiguration['__meta']['exceptionHandler'];
         $invalidExceptionHandlerMessage = 'The class "%s" is not valid for property "@exceptionHandler".';
     } else {
         if ($useInnerExceptionHandler === true) {
             $exceptionHandlerClass = $this->settings['rendering']['innerExceptionHandler'];
         } else {
             $exceptionHandlerClass = $this->settings['rendering']['exceptionHandler'];
         }
         $invalidExceptionHandlerMessage = 'The class "%s" is not valid for setting "Neos.Fusion.rendering.exceptionHandler".';
     }
     $exceptionHandler = null;
     if ($this->objectManager->isRegistered($exceptionHandlerClass)) {
         $exceptionHandler = $this->objectManager->get($exceptionHandlerClass);
     }
     if ($exceptionHandler === null || !$exceptionHandler instanceof AbstractRenderingExceptionHandler) {
         $message = sprintf($invalidExceptionHandlerMessage . "\n" . 'Please specify a fully qualified classname to a subclass of %2$s\\AbstractRenderingExceptionHandler.' . "\n" . 'You might implement an own handler or use one of the following:' . "\n" . '%2$s\\AbsorbingHandler' . "\n" . '%2$s\\HtmlMessageHandler' . "\n" . '%2$s\\PlainTextHandler' . "\n" . '%2$s\\ThrowingHandler' . "\n" . '%2$s\\XmlCommentHandler', $exceptionHandlerClass, 'Neos\\Fusion\\Core\\ExceptionHandlers');
         throw new InvalidConfigurationException($message, 1368788926);
     }
     $exceptionHandler->setRuntime($this);
     if (array_key_exists('__objectType', $typoScriptConfiguration)) {
         $typoScriptPath .= sprintf('<%s>', $typoScriptConfiguration['__objectType']);
     }
     $output = $exceptionHandler->handleRenderingException($typoScriptPath, $exception);
     return $output;
 }
 /**
  * Deserializes a given object tree and reinjects all dependencies.
  *
  * @param array $dataArray The serialized objects array
  * @return array The deserialized objects in an array
  */
 public function deserializeObjectsArray(array $dataArray)
 {
     $this->objectsAsArray = $dataArray;
     $objects = [];
     foreach ($this->objectsAsArray as $objectHash => $objectData) {
         if (!isset($objectData[self::CLASSNAME]) || !$this->objectManager->isRegistered($objectData[self::CLASSNAME])) {
             continue;
         }
         $objects[$objectHash] = $this->reconstituteObject($objectHash, $objectData);
     }
     return $objects;
 }
 /**
  * Returns the class name of an appropriate validator for the given type. If no
  * validator is available FALSE is returned
  *
  * @param string $validatorType Either the fully qualified class name of the validator or the short name of a built-in validator
  * @return string|boolean Class name of the validator or FALSE if not available
  */
 protected function resolveValidatorObjectName($validatorType)
 {
     $validatorType = ltrim($validatorType, '\\');
     $validatorClassNames = static::getValidatorImplementationClassNames($this->objectManager);
     if ($this->objectManager->isRegistered($validatorType) && isset($validatorClassNames[$validatorType])) {
         return $validatorType;
     }
     if (strpos($validatorType, ':') !== false) {
         list($packageName, $packageValidatorType) = explode(':', $validatorType);
         $possibleClassName = sprintf('%s\\Validation\\Validator\\%sValidator', str_replace('.', '\\', $packageName), $this->getValidatorType($packageValidatorType));
     } else {
         $possibleClassName = sprintf('Neos\\Flow\\Validation\\Validator\\%sValidator', $this->getValidatorType($validatorType));
     }
     if ($this->objectManager->isRegistered($possibleClassName) && isset($validatorClassNames[$possibleClassName])) {
         return $possibleClassName;
     }
     return false;
 }
 /**
  * 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();
     }
 }
 /**
  * Returns instance of concrete formatter.
  *
  * The type provided has to be either a name of existing class placed in
  * I18n\Formatter namespace or a fully qualified class name;
  * in both cases implementing this' package's FormatterInterface.
  * For example, when $formatterName is 'number',
  * the I18n\Formatter\NumberFormatter class has to exist; when
  * $formatterName is 'Acme\Foobar\I18nFormatter\SampleFormatter', this class
  * must exist and implement I18n\Formatter\FormatterInterface.
  *
  * Throws exception if there is no formatter for name given or one could be
  * retrieved but does not satisfy the FormatterInterface.
  *
  * @param string $formatterType Either one of the built-in formatters or fully qualified formatter class name
  * @return Formatter\FormatterInterface The concrete formatter class
  * @throws Exception\UnknownFormatterException When formatter for a name given does not exist
  * @throws Exception\InvalidFormatterException When formatter for a name given does not exist
  */
 protected function getFormatter($formatterType)
 {
     $foundFormatter = false;
     $formatterType = ltrim($formatterType, '\\');
     if (isset($this->formatters[$formatterType])) {
         $foundFormatter = $this->formatters[$formatterType];
     }
     if ($foundFormatter === false) {
         if ($this->objectManager->isRegistered($formatterType)) {
             $possibleClassName = $formatterType;
         } else {
             $possibleClassName = sprintf('Neos\\Flow\\I18n\\Formatter\\%sFormatter', ucfirst($formatterType));
             if (!$this->objectManager->isRegistered($possibleClassName)) {
                 throw new Exception\UnknownFormatterException('Could not find formatter for "' . $formatterType . '".', 1278057791);
             }
         }
         if (!$this->reflectionService->isClassImplementationOf($possibleClassName, Formatter\FormatterInterface::class)) {
             throw new Exception\InvalidFormatterException(sprintf('The resolved internationalization formatter class name "%s" does not implement "%s" as required.', $possibleClassName, FormatterInterface::class), 1358162557);
         }
         $foundFormatter = $this->objectManager->get($possibleClassName);
     }
     $this->formatters[$formatterType] = $foundFormatter;
     return $foundFormatter;
 }
 /**
  * Iterates through the given $properties setting them on the specified $node using the appropriate TypeConverters.
  *
  * @param object $nodeLike
  * @param NodeType $nodeType
  * @param array $properties
  * @param TYPO3CRContext $context
  * @param PropertyMappingConfigurationInterface $configuration
  * @return void
  * @throws TypeConverterException
  */
 protected function setNodeProperties($nodeLike, NodeType $nodeType, array $properties, TYPO3CRContext $context, PropertyMappingConfigurationInterface $configuration = null)
 {
     $nodeTypeProperties = $nodeType->getProperties();
     unset($properties['_lastPublicationDateTime']);
     foreach ($properties as $nodePropertyName => $nodePropertyValue) {
         if (substr($nodePropertyName, 0, 2) === '__') {
             continue;
         }
         $nodePropertyType = isset($nodeTypeProperties[$nodePropertyName]['type']) ? $nodeTypeProperties[$nodePropertyName]['type'] : null;
         switch ($nodePropertyType) {
             case 'reference':
                 $nodePropertyValue = $context->getNodeByIdentifier($nodePropertyValue);
                 break;
             case 'references':
                 $nodeIdentifiers = json_decode($nodePropertyValue);
                 $nodePropertyValue = array();
                 if (is_array($nodeIdentifiers)) {
                     foreach ($nodeIdentifiers as $nodeIdentifier) {
                         $referencedNode = $context->getNodeByIdentifier($nodeIdentifier);
                         if ($referencedNode !== null) {
                             $nodePropertyValue[] = $referencedNode;
                         }
                     }
                 } elseif ($nodeIdentifiers !== null) {
                     throw new TypeConverterException(sprintf('node type "%s" expects an array of identifiers for its property "%s"', $nodeType->getName(), $nodePropertyName), 1383587419);
                 }
                 break;
             case 'DateTime':
                 if ($nodePropertyValue !== '' && ($nodePropertyValue = \DateTime::createFromFormat(\DateTime::W3C, $nodePropertyValue)) !== false) {
                     $nodePropertyValue->setTimezone(new \DateTimeZone(date_default_timezone_get()));
                 } else {
                     $nodePropertyValue = null;
                 }
                 break;
             case 'integer':
                 $nodePropertyValue = intval($nodePropertyValue);
                 break;
             case 'boolean':
                 if (is_string($nodePropertyValue)) {
                     $nodePropertyValue = $nodePropertyValue === 'true' ? true : false;
                 }
                 break;
             case 'array':
                 $nodePropertyValue = json_decode($nodePropertyValue, true);
                 break;
         }
         if (substr($nodePropertyName, 0, 1) === '_') {
             $nodePropertyName = substr($nodePropertyName, 1);
             ObjectAccess::setProperty($nodeLike, $nodePropertyName, $nodePropertyValue);
             continue;
         }
         if (!isset($nodeTypeProperties[$nodePropertyName])) {
             if ($configuration !== null && $configuration->shouldSkipUnknownProperties()) {
                 continue;
             } else {
                 throw new TypeConverterException(sprintf('Node type "%s" does not have a property "%s" according to the schema', $nodeType->getName(), $nodePropertyName), 1359552744);
             }
         }
         $innerType = $nodePropertyType;
         if ($nodePropertyType !== null) {
             try {
                 $parsedType = TypeHandling::parseType($nodePropertyType);
                 $innerType = $parsedType['elementType'] ?: $parsedType['type'];
             } catch (InvalidTypeException $exception) {
             }
         }
         if (is_string($nodePropertyValue) && $this->objectManager->isRegistered($innerType) && $nodePropertyValue !== '') {
             $nodePropertyValue = $this->propertyMapper->convert(json_decode($nodePropertyValue, true), $nodePropertyType, $configuration);
         }
         $nodeLike->setProperty($nodePropertyName, $nodePropertyValue);
     }
 }