[TYPO3-50-general] RFC: Arguments with identifiers

Sebastian Kurfürst sebastian at typo3.org
Thu Jan 8 15:33:17 CET 2009


Hello guys,

I have committed the code now - Revision 1715 - and I am curious about  
your comments!

Greets,
Sebastian
Am 08.01.2009 um 10:10 schrieb Sebastian Kurfürst:

> Hey everybody,
>
> I have some ideas how to improve argument handling with respect to
> unique identifiers. Please comment on the ideas, as I want to
> implement them later today for a first draft.
>
> Problem Description:
> While implementing CRUD-functionality, in the "Update" case, I
> stumbled over the following issue:
> - A form of the Domain Object is displayed, and to identify the record
> on the server again, we need some identifier property which is sent
> back to the server. The Form ViewHelper will have support for that.
> - Now, let's assume we edit a "Customer". The data is sent back to the
> server in the following form:
> 	customer[identifier] = identifier-property
> 	customer[name] = Sebastian Kurfürst
> 	customer[city] = Dresden
> - On the server, automatic Property Mapping of the "customer" property
> takes place, thus you get a _new_ instance of a Customer object on the
> server.
> - However, you somehow need a possibility to get the "identifier"
> property, which is not mapped to the domain object - as you need to
> retrieve the right object from the Repository and to the real mapping.
>
> So, the updateAction would look as follows:
>
> // an argument "customer" of the type "F3\Example\Domain\Customer" was
> registered
> public function updateAction() {
> 	$customer = $this->arguments['customer']->getValue();
> 	$customerIdentifier = // GET IDENTIFIER
> 	$persistentCustomer = $this->customerRepository-
>> findByIdentifier($customerIdentifier);
> 	$this->propertyMapper->map($customer, $persistentCustomer);
> }
>
> The problem is how the // GET IDENTIFIER is done.
>
> Proposed solution:
> I'd like to make the "Argument" object aware of an identifier.
> Thus, in the above example, you would write $this-
>> arguments['customer']->getIdentifier() instead of // GET IDENTIFIER.
>
> However, internally, it is not clean if the "Argument" object directly
> checks for the "identifier" array property.
> That's why I'd like to add a new method to PropertyConverters which is
> called "getIdentifier()" - resolving the above identifier.
> As not all PropertyConverters need such a method, I'd encapsulate this
> in a new interface. (Property\Converter\IdentifierFacetInterface or  
> so)
>
> The Property Mapper would do the following:
> - if the PropertyConverter implements the above interface, it calls
> "getIdentifier()" on the PropertyConverter.
> - The returned value is mapped to a defined property on the target
> object by the Property Mapper.
>
> Affected Classes:
> - Argument (new get/setIdentifier method)
> - PorpertyMapper (handling of the interface)
> - DomainObjectPropertyConverter (implements the above interface)
>
> I'm curious about your comments :-)
>
> Greets,
> Sebastian
>
> --
> Gimme five!
> _______________________________________________
> TYPO3-project-5_0-general mailing list
> TYPO3-project-5_0-general at lists.netfielders.de
> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-project-5_0-general

--
Gimme five!



More information about the TYPO3-project-5_0-general mailing list