Feature #30300

Support mapping to subclass by argument

Added by Christopher Hlubek almost 4 years ago. Updated over 3 years ago.

Status:Resolved Start date:2011-09-26
Priority:Should have Due date:
Assigned To:Christopher Hlubek % Done:

100%

Category:Property
Target version:TYPO3 Flow Base Distribution - 1.1 beta 1
PHP Version: Complexity:
Has patch:No

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 subclas... Resolved 2011-12-24
related to Core - Bug #49803: Problems in overriding objects with new property mapper Resolved 2013-07-09

Associated revisions

Revision 41c21ba3
Added by Christopher Hlubek over 3 years ago

[FEATURE] Support mapping to specific subtypes by property (__type)

When type hierarchies are used for modeling, it's sometimes necessary
to use a special subclass when creating new entities (e.g. from user
selection). This change enables the use of a special (request)
property "__type" in the source array of a type converter. For security
reasons, this feature must be configured explicitly through a mapping
configuration.

Resolves: #30300
Releases: 1.1
Change-Id: I6d0a9d62789bd8557a848311e1f13f0c094dc51f

History

#1 Updated by Mr. Hudson almost 4 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 almost 4 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 3 years ago

  • Category set to Property
  • Assigned To set to Christopher Hlubek
  • Target version set to 1.1
  • Has patch set to No

#4 Updated by Mr. Hudson over 3 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 3 years ago

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

#6 Updated by Karsten Dambekalns over 3 years ago

  • Target version changed from 1.1 to 1.1 beta 1

Also available in: Atom PDF