[TYPO3-mvc] URIBuilder rewrite

Bastian Waidelich bastian at typo3.org
Wed Aug 12 10:14:42 CEST 2009


Robert Lemke wrote:

Hi Robert,

> In general I would assume that a builder is singleton and that the build 
> method is called build() and not render.

I agree about the render() method - build() is better!
But I don't think, the UriBuilder should be a singleton:

In Fluid we can use the same instance regardless whether it's a 
singleton or not. And if you use the builder in your code, you'd want to 
manually create a fresh instance and should be able to reuse that (see 
the dummy example in my reply to Sebastians question). So resetting the 
builder in build() would not really work.

Apart from that, you need to inject the current request.. which is a 
prototype too.


>   2) make UriBuilder a prototype to avoid unintended misconfiguration 
> and accept the overhead
>      of creating a new instance everytime we create a link (sounds slow 
> huh?)

I'm in favor of this option. If you look at the current FLOW3/Extbase 
code, the UriBuilder is only used in view helpers and in the 
AbstractController (where it is stored in a protected field anyways)

Bastian


More information about the TYPO3-project-typo3v4mvc mailing list