Example #1
0
 /**
  * Forwards the request to another command and / or CommandController.
  *
  * Request is directly transferred to the other command / controller
  * without the need for a new request.
  *
  * @param string $commandName
  * @param string $controllerObjectName
  * @param array $arguments
  * @return void
  * @throws StopActionException
  */
 protected function forward($commandName, $controllerObjectName = null, array $arguments = [])
 {
     $this->request->setDispatched(false);
     $this->request->setControllerCommandName($commandName);
     if ($controllerObjectName !== null) {
         $this->request->setControllerObjectName($controllerObjectName);
     }
     $this->request->setArguments($arguments);
     $this->arguments->removeAll();
     throw new StopActionException('forward', 1476107661);
 }
 /**
  * Forwards the request to another command and / or CommandController.
  *
  * Request is directly transferred to the other command / controller
  * without the need for a new request.
  *
  * @param string $commandName
  * @param string $controllerObjectName
  * @param array $arguments
  * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
  * @return void
  */
 protected function forward($commandName, $controllerObjectName = NULL, array $arguments = array())
 {
     $this->request->setDispatched(FALSE);
     $this->request->setControllerCommandName($commandName);
     if ($controllerObjectName !== NULL) {
         $this->request->setControllerObjectName($controllerObjectName);
     }
     $this->request->setArguments($arguments);
     $this->arguments->removeAll();
     throw new \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException();
 }
 /**
  * Add support for variable argument lists using a wildcard property name '*'.
  * This is required for a file multiupload, as you can't guess how many files
  * will be uploaded when rendering the form (and generating the
  * trustedPropertiesToken) on the server.
  *
  * You can use it like this:
  * If you write a formfield viewhelper, you have to register all the properties
  * that should be mapped when processing the input on the server. To allow
  * the mapping of some properties of all submitted elements, insert a wildcard
  * in the path at the position where new keys will appear. This class will
  * enable the mapping of all arguments that are assigned to this path.
  *
  * So, if you have this line in your viewhelper:
  *		$this->registerFieldNameForFormTokenGeneration('my_plugin[my_object][object_storage_property][*][foo]');
  * and request arguments like this:
  *		array( 'my_object' => array( 'object_storage_property' => array(
  *			0 => array( 'foo' => 13 ),
  *			1 => array( 'foo' => 42 ),
  *			2 => array( 'foo' => false )
  *		)))
  * the PropertyMapper won't complain about missing permissions to "map
  * attribute my_object.object_storage_property.0".
  *
  * This is different from simply using $propertyMappingConfiguration->allowAllProperties()
  * because:
  * - You don't have to post that line into each of your controllers
  * - You can control which sub-properties to map
  * - You don't override assigned settings for specific keys: if there is a
  *   configuration for my_object.object_storage_property.42, it won't be
  *   changed to the wildcard value.
  *
  * @param \TYPO3\CMS\Extbase\Mvc\Request $request
  * @param \TYPO3\CMS\Extbase\Mvc\Controller\Arguments $controllerArguments
  * @return void
  */
 public function initializePropertyMappingConfigurationFromRequest(\TYPO3\CMS\Extbase\Mvc\Request $request, \TYPO3\CMS\Extbase\Mvc\Controller\Arguments $controllerArguments)
 {
     $trustedPropertiesToken = $request->getInternalArgument('__trustedProperties');
     if (!is_string($trustedPropertiesToken)) {
         return;
     }
     $serializedTrustedProperties = $this->hashService->validateAndStripHmac($trustedPropertiesToken);
     $trustedProperties = unserialize($serializedTrustedProperties);
     foreach ($trustedProperties as $propertyName => $propertyConfiguration) {
         if (!$controllerArguments->hasArgument($propertyName)) {
             continue;
         }
         $propertyMappingConfiguration = $controllerArguments->getArgument($propertyName)->getPropertyMappingConfiguration();
         //
         // Extended from parent class - begin
         //
         if (is_array($propertyConfiguration)) {
             foreach (HelhumArrayUtility::getPathsToKey($propertyConfiguration, '*') as $path) {
                 $configurationTemplate = ExtbaseArrayUtility::getValueByPath($propertyConfiguration, $path . '.*');
                 $propertyConfiguration = ExtbaseArrayUtility::unsetValueByPath($propertyConfiguration, $path . '.*');
                 if ($request->hasArgument($propertyName) && is_array($request->getArgument($propertyName))) {
                     $rawArgument = ExtbaseArrayUtility::getValueByPath($request->getArgument($propertyName), $path);
                     $subPropertyConfiguration = ExtbaseArrayUtility::getValueByPath($propertyConfiguration, $path);
                     foreach ($rawArgument as $index => $_) {
                         if (!is_int($index) || array_key_exists($index, $subPropertyConfiguration)) {
                             continue;
                         }
                         $propertyConfiguration = ExtbaseArrayUtility::setValueByPath($propertyConfiguration, $path . '.' . $index, $configurationTemplate);
                     }
                 }
             }
         }
         //
         // Extended from parent class - end
         //
         $this->modifyPropertyMappingConfiguration($propertyConfiguration, $propertyMappingConfiguration);
     }
 }
 /**
  * Initialize the property mapping configuration in $controllerArguments if
  * the trusted properties are set inside the request.
  *
  * @param \TYPO3\CMS\Extbase\Mvc\Request $request
  * @param \TYPO3\CMS\Extbase\Mvc\Controller\Arguments $controllerArguments
  *
  * @return void
  */
 public function initializePropertyMappingConfigurationFromRequest(\TYPO3\CMS\Extbase\Mvc\Request $request, \TYPO3\CMS\Extbase\Mvc\Controller\Arguments $controllerArguments)
 {
     $trustedPropertiesToken = $request->getInternalArgument('__trustedProperties');
     if (!is_string($trustedPropertiesToken)) {
         return;
     }
     $serializedTrustedProperties = $this->hashService->validateAndStripHmac($trustedPropertiesToken);
     $trustedProperties = unserialize($serializedTrustedProperties);
     foreach ($trustedProperties as $propertyName => $propertyConfiguration) {
         if (!$controllerArguments->hasArgument($propertyName)) {
             continue;
         }
         $propertyMappingConfiguration = $controllerArguments->getArgument($propertyName)->getPropertyMappingConfiguration();
         $this->modifyPropertyMappingConfiguration($propertyConfiguration, $propertyMappingConfiguration);
     }
 }