[TYPO3-team-core-v5] Problem with handling of view classes due to naming/placement scheme

Karsten Dambekalns karsten at typo3.org
Tue Apr 21 08:42:44 CEST 2009


Hi.

While sitting at DFW airport waiting for the flight back home I set out 
to fix the current code of the TYPO3 package.

Most things were simply adjustments to new method names or "EBKAC" type 
of issues (e.g. the problem with aggregate roots being in the object 
tree to be persisted but not being added to their repositories).

One thing needs more consideration, though. The naming and placement 
scheme for view classes has changed since Fluid is around. The new 
scheme is rather intuitive and works well for the Fluid-based code being 
around, as there are only HTML files present as views.

The TYPO3 package uses PHP views in a few places (JSON services) and 
still used the old class name scheme. I this created the needed 
directories, moved/renamed the files and adjusted namespaces and class 
names. Didn't work. Ok, the ActionController in FLOW3 had the old view 
name pattern. Changed that. Now TYPO3CR didn't work any longer. Fixed 
that. Bang - this leads to code like this for the default view of the 
default controller in the TYPO3CR Admin subpackage (in 
TYPO3CR/Classes/Admin/View/Default/IndexHTML.php):

<?php
declare(ENCODING = 'utf-8');
namespace F3\TYPO3CR\Admin\View\Default;
  [...]
class IndexHTML extends \F3\FLOW3\MVC\View\AbstractView {
  [...]
}
?>

Who spots the error? Two words: "reserved words", in this case "default" 
cause syntax errors. This is why we decided on postfixing Controller to 
controller names, as to avoid "class Default ...".

Now, looking up what "default" really means made me think we should have 
used "standard" to begin with, but that would probably confuse IT 
people. So,
* either we ban "Default" only for this case and make it 
"StandardController"
* tell people to always use some descriptive name instead and adjust routing
* change the naming scheme for view so the full controller name used in 
it, so that the above example ends up being "namespace 
F3\TYPO3CR\Admin\View\DefaultController;"
* do the above for PHP and HTML to keep things consistent.

Those are sorted by (IMHO) awkwardness from top to bottom, most awkward 
coming first. I had other ideas as well, they were very weird and I 
forgot them again quickly.

What do you think? Better ideas (hopefully) or at least an opinion on 
the above (better than nothing)?

Regards,
Karsten


More information about the TYPO3-team-core-v5 mailing list