[Flow] allow mapping of subproperty
Alexander Wende
a_wende at web.de
Wed Oct 1 12:56:38 CEST 2014
I have an entity "mitarbeiter" which extends \TYPO3\Party\Domain\Model\Person. My MitarbeiterController works fine but now I have to implement a RestController for "mitarbeiter". The listAction of the RestController works out of the box, but when I try to create a "mitarbeiter", I got "It is not allowed to map property 'firstName'".
I tried several combination of the propertyMapping Configuration. My Current Rest Controller looks like that:
/**
* @Flow\Scope("singleton")
*/
class MitarbeiterController extends \TYPO3\Flow\Mvc\Controller\RestController{
/**
* @Flow\Inject
* @var \Company\Project\Domain\Repository\Organisation\MitarbeiterRepository
*/
protected $mitarbeiterRepository;
protected $defaultViewObjectName = 'TYPO3\Flow\Mvc\View\JsonView';
protected $resourceArgumentName = 'mitarbeiter';
public function listAction(){ #works fine }
/**
* initialize create action
*
* @return void
*/
public function initializeCreateAction() {
$this->arguments['mitarbeiter']->getPropertyMappingConfiguration()->allowProperties('name','name.firstName','name.lastName');
$this->arguments['mitarbeiter']->getPropertyMappingConfiguration()->allowCreationForSubProperty('name');
$this->arguments['mitarbeiter']->getPropertyMappingConfiguration()->allowCreationForSubProperty('name.firstName');
$this->arguments['mitarbeiter']->getPropertyMappingConfiguration()->allowCreationForSubProperty('name.lastName');
}
public function createAction( \Company\Project\Domain\Model\Organisation\Mitarbeiter $mitarbeiter){
$this->mitarbeiterRepository->add($mitarbeiter);
$this->response->setStatus(201);
}
What I am doing wrong?
More information about the Flow
mailing list