N°2060 [WIP] Initialisation of the portal application: Refactor way brick controllers forward actions between each others

This commit is contained in:
Molkobain
2019-07-11 17:44:55 +02:00
parent ee45e546a8
commit cd6fe171cd
4 changed files with 36 additions and 30 deletions

View File

@@ -33,5 +33,32 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
*/
abstract class AbstractController extends Controller
{
/**
* @param string $sRouteName
* @param array $aRouteParams
* @param array $aQueryParameters
*
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function ForwardFromRoute($sRouteName, $aRouteParams, $aQueryParameters)
{
return $this->forward($this->GetControllerNameFromRoute($sRouteName), $aRouteParams, $aQueryParameters);
}
/**
* Returns a string containing the controller and action name of a specific route, typically used for request forwarding.
*
* Example: 'p_object_create' returns 'Combodo\iTop\Portal\Controller\ObjectController::CreateAction'
*
* @param string $sRouteName
*
* @return string
*/
protected function GetControllerNameFromRoute($sRouteName)
{
$oRouteCollection = $this->get('router')->getRouteCollection();
$aRouteDefaults = $oRouteCollection->get($sRouteName)->getDefaults();
return $aRouteDefaults['_controller'];
}
}