[TYPO3-doc] Updated Document model

Fabien Udriot fabien.udriot at ecodev.ch
Wed Aug 29 19:22:49 CEST 2012


Hi,

As reminder, we have a Document model with properties $uri and $local which are both of type string.
There has been the suggestion to use object \TYPO3\FLOW3\Http\Uri and \TYPO3\FLOW3\I18n\Locale newly
introduced in FLOW3 1.1 to benefit from an API and validation at the same time.

However, I faced the problem that declaring the $uri of type \TYPO3\FLOW3\Http\Uri (in the
annotation) was not sufficient for doctrine. The field was simply not created because
\TYPO3\FLOW3\Http\Uri is not an entity. A solution, would have been to create proper entity
extending the Uri object from F3. Though, it looks wrong since Uri would have been part of the
Domain Model which does not make sense considering DDD.

As a result, we sticked to the string property in the model but created an additional getter method
to fetch an object in case. For the curious ones, it roughly looks like below.

class Document {

 /**
  * @var string
  */
 protected $uri

 function getUri($uri) {
    return $uri;
 }

 function getUriObject($uri) {
    return \TYPO3\FLOW3\Http\Uri($uri);
 }
}

The whole Document model looks like that by now:
https://github.com/typo3/TYPO3.Docs/blob/master/Classes/Domain/Model/Category.php

Fabien


More information about the TYPO3-project-documentation mailing list