Feature #30300

Support mapping to subclass by argument

Added by Christopher Hlubek about 10 years ago. Updated almost 10 years ago.

Status:
Resolved
Priority:
Should have
Category:
Property
Start date:
2011-09-26
Due date:
% Done:

100%

Estimated time:
PHP Version:
Has patch:
No
Complexity:

Description

When type hierarchies are used for modeling, it's necessary to map to a special subclass when creating new entities. This should be possible by a special (request) parameter in the source array of a type converter. For security reasons, this feature must be configured explicitly through a mapping configuration.

Example:

class MyProject\MySpecialUser extends MyProject\User

source = {
  __type: 'MyProject\MySpecialUser',
  name: 'Foo'
}

targetType = 'MyProject\User'

In this example, the created type should be an instance of MyProject\MySpecialUser.

The configuration could be given through a property mapping configuration like this:

class MyObjectController {

    /**
     * @return void
     */
    protected function initializeCreateAction() {
        $argument = $this->arguments->getArgument('newMyObject');
        $configuration = $argument->getPropertyMappingConfiguration();
        $configuration->allowOverrideTargetType();
    }

}

If the given type parameter is not an instance of the target type, an exception should be thrown.


Related issues

Related to TYPO3.Flow - Bug #32829: Mapping to a subclass by __type property fails if subclass adds fieldsResolvedAndreas Wolf2011-12-24

Actions
Related to TYPO3 Core - Bug #49803: Problems in overriding objects with new property mapperClosed2013-07-09

Actions

Also available in: Atom PDF