Contao\Controller::replaceOldBePaths PHP Method

replaceOldBePaths() protected static method

Replace the old back end paths
protected static replaceOldBePaths ( string $strContext ) : string
$strContext string The context
return string The modified context
    protected static function replaceOldBePaths($strContext)
    {
        $router = \System::getContainer()->get('router');
        $generate = function ($route) use($router) {
            return substr($router->generate($route), strlen(\Environment::get('path')) + 1);
        };
        $arrMapper = array('contao/confirm.php' => $generate('contao_backend_confirm'), 'contao/file.php' => $generate('contao_backend_file'), 'contao/help.php' => $generate('contao_backend_help'), 'contao/index.php' => $generate('contao_backend_login'), 'contao/main.php' => $generate('contao_backend'), 'contao/page.php' => $generate('contao_backend_page'), 'contao/password.php' => $generate('contao_backend_password'), 'contao/popup.php' => $generate('contao_backend_popup'), 'contao/preview.php' => $generate('contao_backend_preview'), 'contao/switch.php' => $generate('contao_backend_switch'));
        return str_replace(array_keys($arrMapper), array_values($arrMapper), $strContext);
    }

Usage Example

Example #1
0
 /**
  * Convert a string to a response object
  *
  * @param string $str
  *
  * @return Response
  */
 protected function convertToResponse($str)
 {
     return new Response(\Controller::replaceOldBePaths($str));
 }