/**
  * Convert raw property values to the correct type according to a node type configuration
  *
  * @param NodeType $nodeType
  * @param string $propertyName
  * @param string $rawValue
  * @param Context $context
  * @return mixed
  */
 public function convert(NodeType $nodeType, $propertyName, $rawValue, Context $context)
 {
     $propertyType = $nodeType->getPropertyType($propertyName);
     switch ($propertyType) {
         case 'string':
             return $rawValue;
         case 'reference':
             return $this->convertReference($rawValue, $context);
         case 'references':
             return $this->convertReferences($rawValue, $context);
         case 'DateTime':
             return $this->convertDateTime($rawValue);
         case 'integer':
             return $this->convertInteger($rawValue);
         case 'boolean':
             return $this->convertBoolean($rawValue);
         case 'array':
             return $this->convertArray($rawValue);
         default:
             $innerType = $propertyType;
             if ($propertyType !== null) {
                 try {
                     $parsedType = \TYPO3\Flow\Utility\TypeHandling::parseType($propertyType);
                     $innerType = $parsedType['elementType'] ?: $parsedType['type'];
                 } catch (\TYPO3\Flow\Utility\Exception\InvalidTypeException $exception) {
                 }
             }
             if (is_string($rawValue) && $this->objectManager->isRegistered($innerType) && $rawValue !== '') {
                 return $this->propertyMapper->convert(json_decode($rawValue, true), $propertyType, $configuration);
             }
     }
 }
 /**
  * @param string $value
  * @return boolean
  */
 protected function matchValue($value)
 {
     if ($value === NULL || $value === '') {
         return FALSE;
     }
     $className = EmberDataUtility::camelizeClassName($value);
     if ($this->objectManager->isRegistered($className)) {
         $this->setName('modelName');
         $this->value = $className;
         return TRUE;
     }
     return FALSE;
 }
 /**
  * Handle an Exception thrown while rendering TypoScript according to
  * settings specified in TYPO3.TypoScript.rendering.exceptionHandler
  *
  * @param array $typoScriptPath
  * @param \Exception $exception
  * @param boolean $useInnerExceptionHandler
  * @return string
  * @throws \TYPO3\Flow\Mvc\Exception\StopActionException
  * @throws \TYPO3\Flow\Configuration\Exception\InvalidConfigurationException
  * @throws \Exception|\TYPO3\Flow\Exception
  */
 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 "TYPO3.TypoScript.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, 'TYPO3\\TypoScript\\Core\\ExceptionHandlers');
         throw new \TYPO3\Flow\Configuration\Exception\InvalidConfigurationException($message, 1368788926);
     }
     $exceptionHandler->setRuntime($this);
     if (array_key_exists('__objectType', $typoScriptConfiguration)) {
         $typoScriptPath .= sprintf('<%s>', $typoScriptConfiguration['__objectType']);
     }
     $output = $exceptionHandler->handleRenderingException($typoScriptPath, $exception);
     return $output;
 }
 /**
  * @return void
  */
 protected function initializeAction()
 {
     if (!$this->request->hasArgument('modelName')) {
         $this->throwStatus(500, NULL, 'No modelName configuration found in request.');
     }
     $this->receivedData = json_decode($this->request->getHttpRequest()->getContent());
     $arguments = $this->request->getArguments();
     $this->modelName = $arguments['modelName'];
     $repositoryName = str_replace(array('\\Model\\'), array('\\Repository\\'), $this->modelName) . 'Repository';
     if ($this->objectManager->isRegistered($repositoryName)) {
         $this->repository = $this->objectManager->get($repositoryName);
     } else {
         if (!$this->request->getHttpRequest()->getMethod() === 'GET' || !$this->request->hasArgument('model')) {
             $this->throwStatus(500, NULL, 'No repository found for model ' . $this->modelName . '.');
         }
     }
     $lowerUnderScoredModelName = EmberDataUtility::uncamelizeClassName($this->modelName);
     if (isset($this->receivedData->{$lowerUnderScoredModelName})) {
         $this->arguments->getArgument('model')->setDataType($this->modelName);
         $arguments['model'] = (array) $this->receivedData->{$lowerUnderScoredModelName};
         if (isset($arguments['id'])) {
             $arguments['model']['__identity'] = $arguments['id'];
             unset($arguments['id']);
         }
         // HACK: for some reason ember sends <model:ember<uid>:identifier> to the server
         $arguments['model'] = array_map(function ($value) {
             if (substr($value, 0, 1) === '<' && substr($value, -1) === '>') {
                 return array('__identity' => substr($value, strrpos($value, ':') + 1, 36));
             }
             if ($value !== NULL) {
                 return $value;
             }
         }, $arguments['model']);
         // HACK: we should find another way to skip empty values
         foreach ($arguments['model'] as $key => $value) {
             if ($arguments['model'][$key] === NULL) {
                 unset($arguments['model'][$key]);
             }
         }
     }
     if ($this->request->hasArgument('model')) {
         $arguments['model'] = array('__identity' => $arguments['model']);
         $this->arguments->getArgument('model')->setDataType($this->modelName);
     }
     unset($arguments['modelName']);
     $this->request->setArguments($arguments);
 }
示例#5
0
 /**
  * Reset policy service and role repository
  *
  * This is needed to remove cached role entities after resetting the database.
  *
  * @return void
  */
 protected function resetRolesAndPolicyService()
 {
     $this->objectManager->get('TYPO3\\Flow\\Security\\Policy\\PolicyService')->reset();
     if ($this->objectManager->isRegistered('TYPO3\\Flow\\Security\\Policy\\RoleRepository')) {
         $roleRepository = $this->objectManager->get('TYPO3\\Flow\\Security\\Policy\\RoleRepository');
         \TYPO3\Flow\Reflection\ObjectAccess::setProperty($roleRepository, 'newRoles', array(), TRUE);
     }
 }
 /**
  * Load Site- and NodeData Repositories
  * Note: They aren't injected via annotation in order to create a "soft"-dependency to the TYPO3.Neos & TYPO3.TYPO3CR packages
  *
  * @return void
  */
 public function initializeObject()
 {
     if ($this->objectManager->isRegistered('TYPO3\\Neos\\Domain\\Repository\\SiteRepository')) {
         $this->siteRepository = $this->objectManager->get('TYPO3\\Neos\\Domain\\Repository\\SiteRepository');
     }
     if ($this->objectManager->isRegistered('TYPO3\\TYPO3CR\\Domain\\Repository\\NodeDataRepository')) {
         $this->nodeDataRepository = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Repository\\NodeDataRepository');
     }
 }
 /**
  * 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 = array();
     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;
 }
 /**
  * Sets the corresponding party for this account
  *
  * @param \TYPO3\Party\Domain\Model\AbstractParty $party The party object
  * @deprecated since 3.0 something like a party is not attached to the account directly anymore. Fetch your user/party/organization etc. instance on your own using Domain Services or Repositories (see https://jira.typo3.org/browse/FLOW-5)
  * @throws SecurityException
  */
 public function setParty($party)
 {
     if ($this->accountIdentifier === null || $this->accountIdentifier === '') {
         throw new SecurityException('The account identifier for the account where the party is tried to be set is not yet set. Make sure that you set the account identifier prior to calling setParty().', 1397745354);
     }
     if (!$this->objectManager->isRegistered(\TYPO3\Party\Domain\Service\PartyService::class)) {
         throw new SecurityException('The \\TYPO3\\Party\\Domain\\Service\\PartyService is not available. When using the obsolete method \\TYPO3\\Flow\\Security\\Account::getParty, make sure the package TYPO3.Party is installed.', 1397747413);
     }
     /** @var \TYPO3\Party\Domain\Service\PartyService $partyService */
     $partyService = $this->objectManager->get(\TYPO3\Party\Domain\Service\PartyService::class);
     $partyService->assignAccountToParty($this, $party);
 }
 /**
  * Convert raw property values to the correct type according to a node type configuration
  *
  * @param NodeType $nodeType
  * @param string $propertyName
  * @param string $rawValue
  * @param Context $context
  * @return mixed
  */
 public function convert(NodeType $nodeType, $propertyName, $rawValue, Context $context)
 {
     $propertyType = $nodeType->getPropertyType($propertyName);
     switch ($propertyType) {
         case 'string':
             return $rawValue;
         case 'reference':
             return $this->convertReference($rawValue, $context);
         case 'references':
             return $this->convertReferences($rawValue, $context);
         case 'DateTime':
             return $this->convertDateTime($rawValue);
         case 'integer':
             return $this->convertInteger($rawValue);
         case 'boolean':
             return $this->convertBoolean($rawValue);
         case 'array':
             return $this->convertArray($rawValue);
         default:
             $innerType = $propertyType;
             if ($propertyType !== null) {
                 try {
                     $parsedType = \TYPO3\Flow\Utility\TypeHandling::parseType($propertyType);
                     $innerType = $parsedType['elementType'] ?: $parsedType['type'];
                 } catch (\TYPO3\Flow\Utility\Exception\InvalidTypeException $exception) {
                 }
             }
             if ((is_string($rawValue) || is_array($rawValue)) && $this->objectManager->isRegistered($innerType) && $rawValue !== '') {
                 $propertyMappingConfiguration = new MvcPropertyMappingConfiguration();
                 $propertyMappingConfiguration->allowOverrideTargetType();
                 $propertyMappingConfiguration->allowAllProperties();
                 $propertyMappingConfiguration->skipUnknownProperties();
                 $propertyMappingConfiguration->setTypeConverterOption('TYPO3\\Flow\\Property\\TypeConverter\\PersistentObjectConverter', \TYPO3\Flow\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED, true);
                 $propertyMappingConfiguration->setTypeConverterOption('TYPO3\\Flow\\Property\\TypeConverter\\PersistentObjectConverter', \TYPO3\Flow\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, true);
                 return $this->propertyMapper->convert($rawValue, $propertyType, $propertyMappingConfiguration);
             } else {
                 return $rawValue;
             }
     }
 }
 /**
  * Creates and sets the configured access decision voters
  *
  * @param array $voterClassNames Array of access decision voter class names
  * @return void
  * @throws \TYPO3\Flow\Security\Exception\VoterNotFoundException
  */
 protected function createAccessDecisionVoters(array $voterClassNames)
 {
     foreach ($voterClassNames as $voterClassName) {
         if (!$this->objectManager->isRegistered($voterClassName)) {
             throw new \TYPO3\Flow\Security\Exception\VoterNotFoundException('No voter of type ' . $voterClassName . ' found!', 1222267934);
         }
         $voter = $this->objectManager->get($voterClassName);
         if (!$voter instanceof \TYPO3\Flow\Security\Authorization\AccessDecisionVoterInterface) {
             throw new \TYPO3\Flow\Security\Exception\VoterNotFoundException('The found voter class did not implement \\TYPO3\\Flow\\Security\\Authorization\\AccessDecisionVoterInterface', 1222268008);
         }
         $this->accessDecisionVoters[] = $voter;
     }
 }
示例#11
0
 /**
  * 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 \TYPO3\TYPO3CR\Domain\Service\Context $context
  * @throws \TYPO3\Flow\Property\Exception\TypeConverterException
  * @return void
  */
 protected function setNodeProperties($nodeLike, NodeType $nodeType, array $properties, TYPO3CRContext $context)
 {
     $nodeTypeProperties = $nodeType->getProperties();
     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;
                         }
                     }
                 } else {
                     throw new TypeConverterException(sprintf('node type "%s" expects an array of identifiers for its property "%s"', $nodeType->getName(), $nodePropertyName), 1383587419);
                 }
                 break;
             case 'date':
                 if ($nodePropertyValue !== '') {
                     $nodePropertyValue = \DateTime::createFromFormat('!Y-m-d', $nodePropertyValue);
                 } else {
                     $nodePropertyValue = NULL;
                 }
                 break;
         }
         if (substr($nodePropertyName, 0, 1) === '_') {
             $nodePropertyName = substr($nodePropertyName, 1);
             ObjectAccess::setProperty($nodeLike, $nodePropertyName, $nodePropertyValue);
             continue;
         }
         if (!isset($nodeTypeProperties[$nodePropertyName])) {
             throw new TypeConverterException(sprintf('node type "%s" does not have a property "%s" according to the schema', $nodeType->getName(), $nodePropertyName), 1359552744);
         }
         if ($this->objectManager->isRegistered($nodePropertyType) && $nodePropertyValue !== '') {
             $nodePropertyValue = $this->propertyMapper->convert(json_decode($nodePropertyValue, TRUE), $nodePropertyType);
         }
         $nodeLike->setProperty($nodePropertyName, $nodePropertyValue);
     }
 }
 /**
  * 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('TYPO3\\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 \TYPO3\Flow\SignalSlot\Exception\InvalidSlotException if the slot is not valid
  * @api
  */
 public function dispatch($signalClassName, $signalName, array $signalArguments = array())
 {
     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 \TYPO3\Flow\SignalSlot\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 \TYPO3\Flow\SignalSlot\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 \TYPO3\Flow\SignalSlot\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 \TYPO3\Flow\SignalSlot\Exception\InvalidSlotException('The slot method ' . get_class($object) . '->' . $slotInformation['method'] . '() does not exist.', 1245673368);
         }
         call_user_func_array(array($object, $slotInformation['method']), $signalArguments);
     }
 }
 /**
  * Returns instance of concrete formatter.
  *
  * The type provided has to be either a name of existing class placed in
  * \TYPO3\Flow\I18n\Formatter namespace or a fully qualified class name;
  * in both cases implementing this' package's FormatterInterface.
  * For example, when $formatterName is 'number',
  * the \TYPO3\Flow\I18n\Formatter\NumberFormatter class has to exist; when
  * $formatterName is 'Acme\Foobar\I18nFormatter\SampleFormatter', this class
  * must exist and implement TYPO3\Flow\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 \TYPO3\Flow\I18n\Formatter\FormatterInterface The concrete formatter class
  * @throws \TYPO3\Flow\I18n\Exception\UnknownFormatterException When formatter for a name given does not exist
  * @throws \TYPO3\Flow\I18n\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('TYPO3\\Flow\\I18n\\Formatter\\%sFormatter', ucfirst($formatterType));
             if (!$this->objectManager->isRegistered($possibleClassName)) {
                 throw new \TYPO3\Flow\I18n\Exception\UnknownFormatterException('Could not find formatter for "' . $formatterType . '".', 1278057791);
             }
         }
         if (!$this->reflectionService->isClassImplementationOf($possibleClassName, \TYPO3\Flow\I18n\Formatter\FormatterInterface::class)) {
             throw new \TYPO3\Flow\I18n\Exception\InvalidFormatterException('The resolved internationalization formatter class name "' . $possibleClassName . '" does not implement "TYPO3\\Flow\\I18n\\Formatter\\FormatterInterface" as required.', 1358162557);
         }
         $foundFormatter = $this->objectManager->get($possibleClassName);
     }
     $this->formatters[$formatterType] = $foundFormatter;
     return $foundFormatter;
 }
 /**
  * Set user information on the raven context
  */
 protected function setUserContext()
 {
     $objectManager = \TYPO3\Flow\Core\Bootstrap::$staticObjectManager;
     /** @var \TYPO3\Flow\Security\Context $securityContext */
     $securityContext = $objectManager->get('TYPO3\\Flow\\Security\\Context');
     $userContext = array();
     if ($securityContext->isInitialized()) {
         $account = $securityContext->getAccount();
         if ($account !== NULL) {
             $userContext['username'] = $account->getAccountIdentifier();
         }
         if ($this->objectManager->isRegistered('TYPO3\\Party\\Domain\\Service\\PartyService')) {
             $party = $securityContext->getParty();
             if ($party instanceof Person && $party->getPrimaryElectronicAddress() !== NULL) {
                 $userContext['email'] = (string) $party->getPrimaryElectronicAddress();
             } elseif ($party !== NULL && ObjectAccess::isPropertyGettable($party, 'emailAddress')) {
                 $userContext['email'] = (string) ObjectAccess::getProperty($party, 'emailAddress');
             }
         }
     }
     if ($userContext !== array()) {
         $this->client->user_context($userContext);
     }
 }
 /**
  * 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();
     }
 }
 /**
  * @param \Exception $exception
  * @return void
  */
 public function logException(\Exception $exception)
 {
     if (!isset($this->settings['host']) || strlen($this->settings['host']) === 0) {
         return;
     }
     $statusCode = NULL;
     if ($exception instanceof FlowException) {
         $statusCode = $exception->getStatusCode();
     }
     // skip exceptions with status codes matching "skipStatusCodes" setting
     if (isset($this->settings['skipStatusCodes']) && in_array($statusCode, $this->settings['skipStatusCodes'])) {
         return;
     }
     $host = $this->settings['host'];
     $port = isset($this->settings['port']) ? $this->settings['port'] : UdpTransport::DEFAULT_PORT;
     // set chunk size option to wan (default) or lan
     if (isset($this->settings['chunksize']) && strtolower($this->settings['chunksize']) === 'lan') {
         $chunkSize = UdpTransport::CHUNK_SIZE_LAN;
     } else {
         $chunkSize = UdpTransport::CHUNK_SIZE_WAN;
     }
     // setup connection to graylog server
     $transport = new UdpTransport($host, $port, $chunkSize);
     $publisher = new Publisher();
     $publisher->addTransport($transport);
     // set logLevel depending on http status code
     $logLevel = 4;
     // warning
     if ($statusCode === 500) {
         $logLevel = 3;
         // error
     }
     // build message context
     $messageContext = array('full_message' => $exception->getTraceAsString(), 'reference_code' => $exception instanceof FlowException ? $exception->getReferenceCode() : NULL, 'response_status' => $statusCode, 'short_message' => sprintf('%d %s', $statusCode, Response::getStatusMessageByCode($statusCode)), 'code' => $exception->getCode(), 'file' => $exception->getFile(), 'line' => $exception->getLine());
     if ($this->securityContext !== NULL && $this->securityContext->isInitialized()) {
         $account = $this->securityContext->getAccount();
         if ($account !== NULL) {
             $messageContext['authenticated_account'] = $account->getAccountIdentifier() . ' (' . $this->persistenceManager->getIdentifierByObject($account) . ')';
             $messageContext['authenticated_roles'] = implode(', ', array_keys($this->securityContext->getRoles()));
             if ($this->objectManager->isRegistered(PartyService::class)) {
                 /** @var PartyService $partyService */
                 $partyService = $this->objectManager->get(PartyService::class);
                 $person = $partyService->getAssignedPartyOfAccount($account);
                 if ($person instanceof Person) {
                     $messageContext['authenticated_person'] = (string) $person->getName() . ' (' . $this->persistenceManager->getIdentifierByObject($person) . ')';
                 }
             }
         }
     }
     // prepare request details
     if (Bootstrap::$staticObjectManager instanceof ObjectManagerInterface) {
         $bootstrap = Bootstrap::$staticObjectManager->get('TYPO3\\Flow\\Core\\Bootstrap');
         /* @var Bootstrap $bootstrap */
         $requestHandler = $bootstrap->getActiveRequestHandler();
         if ($requestHandler instanceof HttpRequestHandlerInterface) {
             $request = $requestHandler->getHttpRequest();
             $requestData = array('request_domain' => $request->getHeader('Host'), 'request_remote_addr' => $request->getClientIpAddress(), 'request_path' => $request->getRelativePath(), 'request_uri' => $request->getUri()->getPath(), 'request_user_agent' => $request->getHeader('User-Agent'), 'request_method' => $request->getMethod(), 'request_port' => $request->getPort());
             $messageContext = array_merge($messageContext, $requestData);
         }
     }
     // send message to graylog server
     $logger = new Logger($publisher);
     $logger->log($logLevel, $exception->getMessage(), $messageContext);
 }
 /**
  * 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);
     }
 }