Skip to content

Commit

Permalink
[BUGFIX] Load Viewhelper by Namespace if old class name not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Sommer committed Oct 30, 2015
1 parent 40d444f commit 18a57e6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Classes/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ protected function loadViewHelper($helperKey) {
$viewHelperIncludePath = ExtensionManagementUtility::extPath($extensionKey)
. $viewHelperPath . $possibleFilename;

// @todo only dirty solution
if(!class_exists($possibleClassName)) {

This comment has been minimized.

Copy link
@AndreasA

AndreasA Oct 31, 2015

Not that important as the ViewHelpers will most likely be loaded with autoloading now anyway but
the whole method is supposed to include ViewHelpers from paths in the viewHelperIncludePath which this bypasses as the include_once of those file is later which means that the class_exists check is to early if the ViewHelpers were not already loaded during autoloading. Also it would be good to "write" the class into the loadedHelperFiles array that way the next time the whole "find procedure" doesn't have to be done.
Also with this modification the loop itself for possible paths and extension keys is also irrelevant as if the found classname doesn't exist we always return the namespaced viewHelper.

I think the better solution would be to get the namespaced ViewHelper name before the loop as it is rather simple to get that name and check if that class exists, if it does return it, otherwise do the loop as it was.

$namespaceViewHelper = 'ApacheSolrForTypo3\\Solr\\ViewHelper\\' . Util::underscoredToUpperCamelCase($helperKey);
return $namespaceViewHelper;
}

if (file_exists($viewHelperIncludePath)) {
include_once($viewHelperIncludePath);
$this->loadedHelperFiles[strtolower($helperKey)] = array(
Expand Down

0 comments on commit 18a57e6

Please sign in to comment.