mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merge pull request #5834 from tractorcow/pulls/4.0/fix-admin
BUG Fix regressions in custom admin url from #3274
This commit is contained in:
commit
c130e5550d
@ -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() . '/';
|
||||
|
@ -3,7 +3,7 @@
|
||||
<% with $CurrentMember %>
|
||||
<span>
|
||||
<%t LeftAndMain_Menu_ss.Hello 'Hi' %>
|
||||
<a href="{$AbsoluteBaseURL}{$AdminURL}admin/myprofile" class="profile-link">
|
||||
<a href="{$AdminURL}myprofile" class="profile-link">
|
||||
<% if $FirstName && $Surname %>$FirstName $Surname<% else_if $FirstName %>$FirstName<% else %>$Email<% end_if %>
|
||||
</a>
|
||||
</span>
|
||||
|
Loading…
x
Reference in New Issue
Block a user