63361[BUGFIX] Return class alias respecting namespace
Commit message
Review
-
Code review CR +2 Done
- Alexander Schnitzler +2
- Susi Moog +1
-
Verified V +2 Done
- Alexander Schnitzler +2
- Susi Moog +1
- TYPO3com +1 CI
Issues 1
Files 2
Review log 2226
Show 1 earlier messages
-
Daniel Gohlke uploaded patch set 1 02/21/20, 22:34
-
Markus Klein commented on patch set 1 02/21/20, 22:42
Would you mind adding a simple unit test for this function? -
Markus Klein commented on patch set 1 02/21/20, 22:47
\TYPO3\CMS\Extbase\Tests\Unit\Utility\ExtensionUtilityTest::checkResolveControllerAliasFromControllerClassNameDataProvider would be the place to add the respective use case -
Daniel Gohlke commented on patch set 1 02/21/20, 23:11
> Patch Set 1: > > \TYPO3\CMS\Extbase\Tests\Unit\Utility\ExtensionUtilityTest::checkResolveControllerAliasFromControllerClassNameDataProvider > would be the place to add the respective use case I'll change and update the tests. The current Tests doesn't require Controller classes are in Controller folder. What do you think about it? Do we provoke the next mistake? Must there be a case distinction in the method whether the classes are in a Controller directory or not? -
Daniel Gohlke uploaded patch set 2 02/21/20, 23:34
-
Markus Klein commented on patch set 1 02/21/20, 23:34
> Patch Set 1: > > > Patch Set 1: > > > > \TYPO3\CMS\Extbase\Tests\Unit\Utility\ExtensionUtilityTest::checkResolveControllerAliasFromControllerClassNameDataProvider > > would be the place to add the respective use case > > I'll change and update the tests. The current Tests doesn't require Controller classes are in Controller folder. What do you think about it? Do we provoke the next mistake? Must there be a case distinction in the method whether the classes are in a Controller directory or not? I have never used things this way, honestly. So I have no clear vision what might be affected as well or further down the road. -
Daniel Gohlke commented on patch set 2 02/21/20, 23:40
> Patch Set 1: > > > Patch Set 1: > > > > > Patch Set 1: > > > > > > \TYPO3\CMS\Extbase\Tests\Unit\Utility\ExtensionUtilityTest::checkResolveControllerAliasFromControllerClassNameDataProvider > > > would be the place to add the respective use case > > > > I'll change and update the tests. The current Tests doesn't require Controller classes are in Controller folder. What do you think about it? Do we provoke the next mistake? Must there be a case distinction in the method whether the classes are in a Controller directory or not? > > I have never used things this way, honestly. So I have no clear vision what might be affected as well or further down the road. I created a new patchset. Test are now green. The Convention over Configuration says yes, that the controllers belong in the corresponding folder. However, the tests also allowed other solutions. I'm not sure what was allowed so far. I changed the code to check again if "Controller\\\" is in the namespace, if not, the previous alias is used, otherwise everything from "Controller\\\" of the class name is returned. -
Daniel Gohlke commented on patch set 2 02/21/20, 23:42
Hi Alex, can you have a look at my changes please. -
Daniel Gohlke wrote 02/21/20, 23:42
Removed reviewer Markus Klein. -
Markus Klein commented on patch set 2 CR -1 02/22/20, 00:19
ExtensionUtilityTest.php:489UnresolvedThis is the same test case as in line 477. It also works with the old implementation. -
Markus Klein commented on patch set 3 02/22/20, 00:20
Published edit on patch set 2. -
Markus Klein voted on patch set 3 V +1 CR +1 02/22/20, 00:20
-
TYPO3com voted on patch set 1 V -1 02/22/20, 00:22 Completed build in 41m 02s on Sat, 22 Feb, 12:22 AM Test Summary: 18 of 71974 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-443
-
TYPO3com voted on patch set 2 V +1 02/22/20, 01:56 Completed build in 2h 14m 05s on Sat, 22 Feb, 01:56 AM Test Summary: 71530 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-448
-
TYPO3com voted on patch set 3 V +1 02/22/20, 02:27 Completed build in 40m 20s on Sat, 22 Feb, 02:27 AM Test Summary: 71524 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-450
-
Alexander Schnitzler commented on patch set 3 V -1 02/22/20, 09:49
Putting a -1 here just for the time being to indicate to not merge this yet. I am looking into this today. My gut tells me this might cause problems further down the road. -
Alexander Schnitzler wrote 02/22/20, 10:14
Topic set to extbase -
Alexander Schnitzler commented on patch set 3 02/22/20, 11:41
ExtensionUtility.php:321So, here is an explanation on why I don't like this solution: My general idea is to achieve that a controller does not need to be a class any more. It may, but it doesn't need to. In a future version of TYPO3 I want to be able to define a callable as a controller/action pair, no matter the context. This can be a class like now, or a simple function that returns content. To achieve this I am currently removing the bond between namespaces and logic. I violate "convention over configuration" here because when looking at TYPO3 until 9, the convention was clear but there was no way to break with it through configuration. That's not what "convention over configuration" promises. The idea is to have a sensible default and the possibility to not follow that. Defining class names instead of class aliases gives us the possibility to freely define namespaces and folder structures. Where a class is located doesn't matter. My opinion goes even further: My application shouldn't know about where the code is located and it mustn't derive information from it. Putting controller in a folder Controller is probably a good idea for us humans but it has no meaning for applications. My idea of convention over configuration would now be: The convention is, that we derive the controller alias from the controller name, and really just the name. > FooController -> Foo This logic is in place. What is missing is a chance to override that as a user if two controller aliases collide. This only happens in the context of a plugin. Example: > \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( > 'ControllerAliasTest', > 'test', > [ > \Schnitzler\ControllerAliasTest\Controller\FooController::class => 'index', > \Schnitzler\ControllerAliasTest\Controller\Bar\FooController::class => 'index', > ] > ); In this example, there is a conflict as one plugin handles two controllers that have the same name. One solution is the one you proposed here. Look at the namespace, and automatically add the Bar to the alias, resulting in an alias Bar\Foo, which also exposes the directory structure to the outside world when linking to this nested controller. > &tx_controlleraliastest_test[controller]=Bar\Foo My idea is to implement this differently. We need to give the users the possibility to define a custom controller alias, whose only function is to address the controller class in a plugin environment. Unfortunately this is just the first part of the issue. ----- The next issue is, that we automatically choose the right fluid template for users, also based on the namespace. And again, putting files in folders that reflect the structure of the controller is a good thing for humans but it doesn't make any sense to enforce this. Luckily we have the chance to override the template file in the controller. So this isn't so much a problem after all. What we could do now is to add the possibility to configure all this with TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin() but I think we shouldn't mix up too many things. The controller alias could be used to locate the fluid template but I think this is actually a bad idea because I too often realized that I and others didn't know where templates should be located by default. With a dozen of possibilities to override the base path and the chosen template, I think this logic shouldn't be something to be automated at all. I'd like to have something like this: > return $this->view->render('Bar/Foo.html') The only convention here would be that the default folder for templates is defined. (Ext:Resources/Templates/). My overall goal is to give the user a guideline and all the freedom he/she needs at the same time. Over the last months I realized that this is a tough thing to do and I regularly fail but I try my best. ------- Having all this said, I'd like to think about an alternative solution. The algorithm that resolves the controller alias from the controller class name shouldn't be touched. I will think about it, get in touch with Benni and provide a solution. -
Daniel Gohlke commented on patch set 3 02/22/20, 13:52
ExtensionUtility.php:321ReplyOK, I understand your goal for the future. But the current logic generates the same aliases for different Classes. Not even for your example above. If two Classes have the same name they get the same aliases. An alias should be unique. And currently the aliases are used to determine the template folder with the template files. I think that you have to keep the previous possibilities as long as there are no possibilities to overwrite that. And I think that mapping the folder structure in the controller directory to the template directory is not a convention you can't stick to. If there was a viable other solution that could be implemented in TYPO3 v10 without having to rename all controllers in extensions and especially without having to rebuild the structure of the complete template folder, that would be OK for me. However, in my opinion an alias should be unique. However this uniqueness is calculated. -
Alexander Schnitzler commented on patch set 3 02/23/20, 11:02
ExtensionUtility.php:321Reply UnresolvedYou are absolutely right. The alias must be unique in the context of a plugin and this is currently not the case. If I don't find another solution, I will merge this patch, just to have the current way working again. I am currently experimenting with another way to define plugins which would solve this issue but I have to discuss this the upcoming week with Benni. I promise that you don't have to rename your controllers in version 10. Also, you will not have to restructure fluid template folders. -
Alexander Schnitzler uploaded patch set 4 02/24/20, 19:22
-
TYPO3com voted on patch set 4 V +1 02/24/20, 19:36 Completed build in 12m 59s on Mon, 24 Feb, 07:36 PM Test Summary: 71601 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-648
-
Alexander Schnitzler voted on patch set 4 V +1 CR +1 02/24/20, 19:36
-
Susi Moog voted on patch set 4 V +1 CR +1 02/24/20, 19:43
-
Alexander Schnitzler voted on patch set 4 V +2 CR +2 02/24/20, 19:45
-
Alexander Schnitzler merged patch set 5 02/24/20, 19:46