[TYPO3-doc] Updated Document model

Fabien Udriot fabien.udriot at ecodev.ch
Wed Aug 22 10:21:56 CEST 2012


Hi!

Thanks for all your replies.

>> * Added the property "origin". I am not totally happy with the name, I must say. I have other
>> suggestion such as "source" or "subtype". I would need to track the info where the package comes
>> from:  ter, git, svn because documents are going to be handled differently. We could also exploit
>> more the field "type" to make the distinguish but I am not convinced. Would you have an opinion?
> 
> It's not clear enough to me what you want to track (and I guess that explains partly the diverging
> opinions on naming). Is it just the type of source (as you mention "ter", "git" or "svn") or would
> it be URIs to these resources (i.e. URL of SVN or Git repository, URL of TER archive)? If the
> latter, then "source" is a good choice IMO. If the former, I would quite go with "sourceType" too.

I rather need to track the type of the source ("ter", "git" or "svn") and "sourceType" sounds good
for this purpose.

FYI, URL of TER extensions can easily be computed through helper functions given an extension name
and a version. Though, for Git URL it could be more tricky to calculate the path given a package
name and we could possibly store the source URL as well. Though, let see in the implementation what
are the real needs. I am not finished with the Git part.

>> * Classes/Domain/Model/Uri.php extending \TYPO3\FLOW3\Http\Uri
>> * Classes/Domain/Model/Locale.php extending \TYPO3\FLOW3\I18n\Locale
> 
> Just to understand, was it necessary to create the two models? Can't the base classes be used
> directly? Do you expect us to have specials and thus have to extend the original classes anyway?

It was necessary (to my knowledge) to extend the class and thus create models for two reasons:

1. The extended class adds an entity annotation (@FLOW3\Entity) in order to be persistable.
2. The extended class overrides the constructor, which will set default empty value to properties
that are NULL by default. Otherwise, the entity will not be persisted with a complain of Doctrine.

Check the example of property:

protected $host = NULL (parent class)

-> should be set to $this->host = '' to be persisted.


>> * Classes/Domain/Repository/UriRepository.php enabling to query the URI repository.
> 
> Do we need the repository because the URIs are handled as objects? But then why not a locale
> repository? I guess my FLOW3 notions are not yet stellar ;-)

Well, making myself the first steps with FLOW3, let me expose the problematic. I am using the URI as
kind of identifier to retrieve one document in the database. The URI will also be used for the final
online URL which could look something like: http://docs.typo3.org/[URI].

Before, we had the URI object, I could write the code below to check whether a document exist:

$uri = '/TYPO3/Extensions/a21glossary/0.4.7'
$document = $documentRepository->findOneByUri($uri)
if (count(document) == 1) echo 'Good, there is one!!'

Since now, we are dealing with uri object, I had to change the code like that:

$path = '/TYPO3/Extensions/a21glossary/0.4.7'
$uri = $uriRepository->findOneByPath($path)
$document = $documentRepository->findOneByUri($uri)
if (count(document) == 1) echo 'Good, there is one!!'

This is not very straight forward... I am not aware of something better. Though, what we could
introduce is an "identifier" property which corresponds to the path of the uri. Furthermore, we can
add a constrain to have the unique values to this property. Then, we could have this code:

$identifier = '/TYPO3/Extensions/a21glossary/0.4.7'
$document = $documentRepository->findOneByIdentifier($identifier)
if (count(document) == 1) echo 'Good, there is one!!'

Having that, we could drop the uriRepository.

I hope it is clear enough...

Fb.


More information about the TYPO3-project-documentation mailing list