Feature #34866
Allow fluently working with PropertyMappingConfiguration
Status: | Resolved | Start date: | 2012-03-15 | |
---|---|---|---|---|
Priority: | Should have | Due date: | ||
Assigned To: | Adrian Föder | % Done: | 100% |
|
Category: | MVC | |||
Target version: | TYPO3 Flow Base Distribution - 2.0 beta 1 | |||
PHP Version: | Complexity: | easy | ||
Has patch: | No |
Description
Consider the following use case:
1<?php
2
3class SampleController extends \TYPO3\FLOW3\MVC\Controller\ActionController
4 /**
5 * this magic method is automatically called prior the appropriate createAction
6 */
7 public function initializeCreateAction() {
8 $concreteClassName = $this->dummyFindOutConcreteProductProductClassName();
9
10 /* @var $this->arguments['product'] \TYPO3\FLOW3\MVC\Controller\Argument (just for this example, please don't use in production code */
11 $this->arguments['product']->setDataType($concreteClassName);
12
13 $this->arguments['product']->getPropertyMappingConfiguration()->setTargetType($intendedRatingClassName);
14 $this->arguments['product']->getPropertyMappingConfiguration()->setTargetTypeForSubProperty('author', 'TYPO3\Party\Domain\Model\Person');
15 $this->arguments['product']->getPropertyMappingConfiguration()->allowCreationForSubProperty('author');
16 $this->arguments['product']->getPropertyMappingConfiguration()->allowCreationForSubProperty('author.name');
17
18 }
19
20 /**
21 * Create a new product; expect any concrete product type.
22 * @param \Acme\Northwind\Domain\Model\AbstractProduct $product So far any kind of product
23 * @return void
24 */
25 public function createAction(\Acme\Northwind\Domain\Model\AbstractProduct $product) {
26 }
27}
28?>
so most possible setter methods of \TYPO3\FLOW3\Property\PropertyMappingConfiguration
, and hence \TYPO3\FLOW3\MVC\Controller\MvcPropertyMappingConfiguration
should return $this
in order to allow a fluent coding, e.g.
1 $this->arguments['product']->getPropertyMappingConfiguration()
2 ->setTargetType($intendedRatingClassName);
3 ->setTargetTypeForSubProperty('author', 'TYPO3\Party\Domain\Model\Person');
4 ->allowCreationForSubProperty('author');
5 ->allowCreationForSubProperty('author.name');
6
Associated revisions
[FEATURE] Fluent Interface for PropertyMappingConfiguration methods
Setter and other methods not intended to return particular
values now return $this in order to provide a Fluent Interface
that allows chaining of multiple calls to the same object.
Change-Id: I3f89d314a7b905f5e8940362a71b859095bf43c1
Resolves: #34866
Releases: 1.2
History
#1 Updated by Adrian Föder over 3 years ago
- Status changed from New to Accepted
- Assigned To set to Adrian Föder
- Complexity set to easy
#2 Updated by Gerrit Code Review over 3 years ago
- Status changed from Accepted to Under Review
Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/9843
#3 Updated by Gerrit Code Review about 3 years ago
Patch set 2 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/9843
#4 Updated by Gerrit Code Review about 3 years ago
Patch set 3 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/9843
#5 Updated by Gerrit Code Review about 3 years ago
Patch set 4 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/9843
#6 Updated by Sebastian Kurfuerst about 3 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
#7 Updated by Sebastian Kurfuerst about 3 years ago
- Target version set to 2.0 beta 1