Skip to content

Commit

Permalink
Fixes after CR
Browse files Browse the repository at this point in the history
  • Loading branch information
godefroy-le-hardi committed Jan 9, 2025
1 parent ad26582 commit 040d5f8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 15 deletions.
5 changes: 3 additions & 2 deletions source/Core/Routing/ControllerClassNameResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ public function getClassNameById($classId)
public function getIdByClassName($className)
{
$controllers = ContainerFacade::getParameter('oxid.controllers_map');
if (in_array($className, $controllers)) {
return array_search($className, $controllers, true);
$classId = array_search($className, $controllers, true);
if ($classId) {
return $classId;
}

$classId = $this->getClassIdFromShopMap($className);
Expand Down
25 changes: 16 additions & 9 deletions source/Core/ShopControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,20 +342,22 @@ protected function initializeViewObject($class, $function, $parameters = null, $
$classKey = Registry::getControllerClassNameResolver()->getIdByClassName($class);
$classKey = !is_null($classKey) ? $classKey : $class; //fallback

/** @var FrontendController $view */
$view = ContainerFacade::has($class) ? ContainerFacade::get($class) : oxNew($class);
/** @var ControllerInterface $controller */
$controller = $this->isServiceController($classKey, $class)
? ContainerFacade::get($class)
: oxNew($class);

$view->setClassKey($classKey);
$view->setFncName($function);
$view->setViewParameters($parameters);
$controller->setClassKey($classKey);
$controller->setFncName($function);
$controller->setViewParameters($parameters);

Registry::getConfig()->setActiveView($view);
Registry::getConfig()->setActiveView($controller);

$this->onViewCreation($view);
$this->onViewCreation($controller);

$view->init();
$controller->init();

return $view;
return $controller;
}

/**
Expand Down Expand Up @@ -889,4 +891,9 @@ private function passSessionErrorsToViewData(ControllerInterface $view, array $v
}
return $viewData;
}

private function isServiceController(string $classKey, string $class): bool
{
return isset(ContainerFacade::getParameter('oxid.controllers_map')[$classKey]) && ContainerFacade::has($class);
}
}
11 changes: 7 additions & 4 deletions source/Internal/Framework/Controller/ControllerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\EshopCommunity\Internal\Framework\Controller;

interface ControllerInterface
Expand Down Expand Up @@ -35,7 +33,12 @@ public function getViewData();

public function getViewId();

public function getCharSet();

public function getIsCallForCache();

/*
* @deprecated
*
* Added only for BC and will be removed in the next major with 'charset' language string.
*/
public function getCharSet();
}

0 comments on commit 040d5f8

Please sign in to comment.