From 7c24703804f31d9ef1eab749a7bb5527f7d52624 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Fri, 22 Jul 2016 10:56:35 +1200 Subject: [PATCH] BUG Fix regressions in custom admin url from #3274 --- admin/code/AdminRootController.php | 23 ++++++++++--------- .../Includes/LeftAndMain_MenuStatus.ss | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/admin/code/AdminRootController.php b/admin/code/AdminRootController.php index d138875e2..89e7e0f8f 100644 --- a/admin/code/AdminRootController.php +++ b/admin/code/AdminRootController.php @@ -8,29 +8,30 @@ use SilverStripe\ORM\DataModel; */ class AdminRootController extends Controller implements TemplateGlobalProvider { + /** + * Fallback admin URL in case this cannot be infered from Director.rules + * + * @var string + * @config + */ + private static $url_base = 'admin'; + /** * Convenience function to return the admin route config. * Looks for the {@link Director::$rules} for the current admin Controller. + * + * @return string */ public static function get_admin_route() { - if (Controller::has_curr()) { - $routeParams = Controller::curr()->getRequest()->routeParams(); - $adminControllerClass = isset($routeParams['Controller']) ? $routeParams['Controller'] : get_called_class(); - } - else { - $adminControllerClass = get_called_class(); - } - $rules = Config::inst()->get('Director', 'rules'); - $adminRoute = array_search($adminControllerClass, $rules); - return $adminRoute ? $adminRoute : ''; + $adminRoute = array_search(__CLASS__, $rules); + return $adminRoute ?: static::config()->url_base; } /** * Returns the root admin URL for the site with trailing slash * * @return string - * @uses get_admin_route() */ public static function admin_url() { return self::get_admin_route() . '/'; diff --git a/admin/templates/Includes/LeftAndMain_MenuStatus.ss b/admin/templates/Includes/LeftAndMain_MenuStatus.ss index 3226623fc..8cb203f44 100644 --- a/admin/templates/Includes/LeftAndMain_MenuStatus.ss +++ b/admin/templates/Includes/LeftAndMain_MenuStatus.ss @@ -3,7 +3,7 @@ <% with $CurrentMember %> <%t LeftAndMain_Menu_ss.Hello 'Hi' %> - + <% if $FirstName && $Surname %>$FirstName $Surname<% else_if $FirstName %>$FirstName<% else %>$Email<% end_if %>