[TYPO3-50-general] Refactoring-help needed
Bastian Waidelich
bastian at typo3.org
Sat Dec 6 11:44:28 CET 2008
Christoph Blömer wrote:
Hi Christoph,
> Input: $this->uriPatternSegments, right?
> Output: Boolean or $matchResults?
It's in F3::FLOW3::MVC::Web::Routing::Route->matches() and the input is
the current request path. $this->uriPatternSegments is an ArrayObject
with one element for each segment (/this is one segment/) of the URI
pattern of this route.
Each element again contains one or more so called Route Parts.
The return value of matches() is TRUE or FALSE. $matchResults gets
stored in an internal field.
> I think the Booleans should be replaced with Exceptions. So you have
> only a $matchResult or it throws an exception.
That was Julles suggestion too (see
http://scratchpad.cmlenz.net/315eb5d3538ea3dcd13944215fce886c/). I don't
really agree as you can read in the comments. But anyways, "throw new
Exception('bla bla bla');" instead of "return FALSE;" wouldn't reduce
the complexity IMO.
> Can you give me an example how the input and output looks like?
Each Route consists of the URI pattern and (possibly) default values for
the dynamic Route parts:
> 'typo3/service/v1/[@controller](.[@format])'
In this example $this->uriSegments contains 4 elements:
1: static Route Part "typo3"
2: static Route Part "service"
3: static Route Part "v1"
4: dynamic Route Part "@controller", optional static Route Part ".",
optional dynamic Route Part "@format"
> The [ ] brackets are mostly used for an optional argument.
They used to be optional cause you wouldn't need them when you specify a
default value. Anyways, with the notion of "optional Route Parts"
(everything between round brackets) this changes and you'll explicitly
have to mark parts optional. So I'm thinking of changing the square
brackets to curly brackets {}.
..But that all won't help making the code more readable ;)
Thanks for your feedback!
Bastian
More information about the TYPO3-project-5_0-general
mailing list