Feature #30300

Support mapping to subclass by argument

Added by Christopher Hlubek over 9 years ago. Updated over 9 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
#1

Updated by Mr. Hudson over 9 years ago

  • Status changed from New to Under Review

Patch set 2 of change I6d0a9d62789bd8557a848311e1f13f0c094dc51f has been pushed to the review server.
It is available at http://review.typo3.org/5355

#2

Updated by Mr. Hudson over 9 years ago

Patch set 3 of change I6d0a9d62789bd8557a848311e1f13f0c094dc51f has been pushed to the review server.
It is available at http://review.typo3.org/5355

#3

Updated by Karsten Dambekalns over 9 years ago

  • Category set to Property
  • Assignee set to Christopher Hlubek
  • Target version set to 1.1
  • Has patch set to No
#4

Updated by Mr. Hudson over 9 years ago

Patch set 4 of change I6d0a9d62789bd8557a848311e1f13f0c094dc51f has been pushed to the review server.
It is available at http://review.typo3.org/5355

#5

Updated by Christopher Hlubek over 9 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
#6

Updated by Karsten Dambekalns over 9 years ago

  • Target version changed from 1.1 to 1.1 beta 1

Also available in: Atom PDF