/**
  * @test
  */
 public function getTargetPropertyNameShouldReturnTheUnmodifiedPropertyNameWithoutConfiguration()
 {
     $defaultConfiguration = $this->propertyMappingConfigurationBuilder->build();
     $this->assertTrue($defaultConfiguration->getConfigurationValue('TYPO3\\FLOW3\\Property\\TypeConverter\\PersistentObjectConverter', \TYPO3\FLOW3\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED));
     $this->assertTrue($defaultConfiguration->getConfigurationValue('TYPO3\\FLOW3\\Property\\TypeConverter\\PersistentObjectConverter', \TYPO3\FLOW3\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED));
     $this->assertNull($defaultConfiguration->getConfigurationFor('foo')->getConfigurationValue('TYPO3\\FLOW3\\Property\\TypeConverter\\PersistentObjectConverter', \TYPO3\FLOW3\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED));
     $this->assertNull($defaultConfiguration->getConfigurationFor('foo')->getConfigurationValue('TYPO3\\FLOW3\\Property\\TypeConverter\\PersistentObjectConverter', \TYPO3\FLOW3\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED));
 }
 /**
  * @param array<\TYPO3\TYPO3CR\Domain\Model\NodeInterface> $nodes
  * @param string $action
  * @return void
  */
 public function publishOrDiscardNodesAction(array $nodes, $action)
 {
     $propertyMappingConfiguration = $this->propertyMappingConfigurationBuilder->build();
     $propertyMappingConfiguration->setTypeConverterOption('TYPO3\\TYPO3\\Routing\\NodeObjectConverter', \TYPO3\TYPO3\Routing\NodeObjectConverter::REMOVED_CONTENT_SHOWN, TRUE);
     foreach ($nodes as $key => $node) {
         $nodes[$key] = $this->propertyMapper->convert($node, 'TYPO3\\TYPO3CR\\Domain\\Model\\NodeInterface', $propertyMappingConfiguration);
     }
     switch ($action) {
         case 'publish':
             foreach ($nodes as $node) {
                 $this->workspacesService->publishNode($node);
             }
             $message = 'Selected changes have been published';
             break;
         case 'discard':
             foreach ($nodes as $node) {
                 $this->nodeRepository->remove($node);
             }
             $message = 'Selected changes have been discarded';
             break;
         default:
             throw new \RuntimeException('Invalid action "' . $action . '" given.', 1346167441);
     }
     $this->flashMessageContainer->addMessage(new \TYPO3\FLOW3\Error\Message($message));
     $this->redirect('index');
 }
Example #3
0
 /**
  * Map $source to $targetType, and return the result.
  *
  * If $source is an object and already is of type $targetType, we do return the unmodified object.
  *
  * @param mixed $source the source data to map. MUST be a simple type, NO object allowed!
  * @param string $targetType The type of the target; can be either a class name or a simple type.
  * @param \TYPO3\FLOW3\Property\PropertyMappingConfigurationInterface $configuration Configuration for the property mapping. If NULL, the PropertyMappingConfigurationBuilder will create a default configuration.
  * @return mixed an instance of $targetType
  * @throws \TYPO3\FLOW3\Property\Exception
  * @api
  */
 public function convert($source, $targetType, \TYPO3\FLOW3\Property\PropertyMappingConfigurationInterface $configuration = NULL)
 {
     if ($configuration === NULL) {
         $configuration = $this->configurationBuilder->build();
     }
     $currentPropertyPath = array();
     $this->messages = new \TYPO3\FLOW3\Error\Result();
     try {
         $result = $this->doMapping($source, $targetType, $configuration, $currentPropertyPath);
         if ($result instanceof \TYPO3\FLOW3\Error\Error) {
             return NULL;
         }
         return $result;
     } catch (\Exception $e) {
         throw new \TYPO3\FLOW3\Property\Exception('Exception while property mapping for target type "' . $targetType . '", at property path "' . implode('.', $currentPropertyPath) . '": ' . $e->getMessage(), 1297759968, $e);
     }
 }