Update requesthandlers with missing extension points

This commit is contained in:
Damian Mooyman 2018-03-23 15:28:00 +13:00
parent 28255b79eb
commit 386ef27f65
No known key found for this signature in database
GPG Key ID: 78B823A10DE27D1A
6 changed files with 46 additions and 38 deletions

View File

@ -363,7 +363,9 @@ class FormField extends RequestHandler
*/ */
public function Link($action = null) public function Link($action = null)
{ {
return Controller::join_links($this->form->FormAction(), 'field/' . $this->name, $action); $link = Controller::join_links($this->form->FormAction(), 'field/' . $this->name, $action);
$this->extend('updateLink', $link, $action);
return $link;
} }
/** /**

View File

@ -85,15 +85,15 @@ class FormRequestHandler extends RequestHandler
// Respect FormObjectLink() method // Respect FormObjectLink() method
if ($controller->hasMethod("FormObjectLink")) { if ($controller->hasMethod("FormObjectLink")) {
return Controller::join_links( $base = $controller->FormObjectLink($this->form->getName());
$controller->FormObjectLink($this->form->getName()), } else {
$action, $base = Controller::join_links($controller->Link(), $this->form->getName());
'/'
);
} }
// Default form link // Join with action and decorate
return Controller::join_links($controller->Link(), $this->form->getName(), $action, '/'); $link = Controller::join_links($base, $action, '/');
$this->extend('updateLink', $link, $action);
return $link;
} }
/** /**

View File

@ -7,7 +7,6 @@ use Psr\Container\NotFoundExceptionInterface;
use SilverStripe\Control\Controller; use SilverStripe\Control\Controller;
use SilverStripe\Control\HTTPResponse; use SilverStripe\Control\HTTPResponse;
use SilverStripe\Control\RequestHandler; use SilverStripe\Control\RequestHandler;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Injector\Injector; use SilverStripe\Core\Injector\Injector;
use SilverStripe\ORM\FieldType\DBDatetime; use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\ORM\FieldType\DBField; use SilverStripe\ORM\FieldType\DBField;
@ -25,9 +24,11 @@ class ChangePasswordHandler extends RequestHandler
protected $authenticator; protected $authenticator;
/** /**
* Link to this handler
*
* @var string * @var string
*/ */
protected $link; protected $link = null;
/** /**
* @var array Allowed Actions * @var array Allowed Actions
@ -123,8 +124,8 @@ class ChangePasswordHandler extends RequestHandler
. '<p>You can request a new one <a href="{link1}">here</a> or change your password after' . '<p>You can request a new one <a href="{link1}">here</a> or change your password after'
. ' you <a href="{link2}">logged in</a>.</p>', . ' you <a href="{link2}">logged in</a>.</p>',
[ [
'link1' => $this->link('lostpassword'), 'link1' => $this->Link('lostpassword'),
'link2' => $this->link('login') 'link2' => $this->Link('login')
] ]
) )
); );
@ -164,16 +165,15 @@ class ChangePasswordHandler extends RequestHandler
/** /**
* Return a link to this request handler. * Return a link to this request handler.
* The link returned is supplied in the constructor * The link returned is supplied in the constructor
* @param null $action *
* @param string|null $action
* @return string * @return string
*/ */
public function link($action = null) public function Link($action = null)
{ {
if ($action) { $link = Controller::join_links($this->link, $action);
return Controller::join_links($this->link, $action); $this->extend('updateLink', $link, $action);
} return $link;
return $this->link;
} }
/** /**

View File

@ -41,9 +41,11 @@ class LoginHandler extends RequestHandler
]; ];
/** /**
* @var string Called link on this handler * Link to this handler
*
* @var string
*/ */
private $link; protected $link = null;
/** /**
* @param string $link The URL to recreate this request handler * @param string $link The URL to recreate this request handler
@ -59,16 +61,15 @@ class LoginHandler extends RequestHandler
/** /**
* Return a link to this request handler. * Return a link to this request handler.
* The link returned is supplied in the constructor * The link returned is supplied in the constructor
*
* @param null|string $action * @param null|string $action
* @return string * @return string
*/ */
public function link($action = null) public function Link($action = null)
{ {
if ($action) { $link = Controller::join_links($this->link, $action);
return Controller::join_links($this->link, $action); $this->extend('updateLink', $link, $action);
} return $link;
return $this->link;
} }
/** /**
@ -152,7 +153,7 @@ class LoginHandler extends RequestHandler
public function getReturnReferer() public function getReturnReferer()
{ {
return $this->link(); return $this->Link();
} }
/** /**

View File

@ -44,7 +44,12 @@ class LostPasswordHandler extends RequestHandler
'passwordsent', 'passwordsent',
]; ];
private $link = null; /**
* Link to this handler
*
* @var string
*/
protected $link = null;
/** /**
* @param string $link The URL to recreate this request handler * @param string $link The URL to recreate this request handler
@ -59,16 +64,14 @@ class LostPasswordHandler extends RequestHandler
* Return a link to this request handler. * Return a link to this request handler.
* The link returned is supplied in the constructor * The link returned is supplied in the constructor
* *
* @param string $action * @param string|null $action
* @return string * @return string
*/ */
public function link($action = null) public function Link($action = null)
{ {
if ($action) { $link = Controller::join_links($this->link, $action);
return Controller::join_links($this->link, $action); $this->extend('updateLink', $link, $action);
} return $link;
return $this->link;
} }
/** /**
@ -261,7 +264,7 @@ class LostPasswordHandler extends RequestHandler
protected function redirectToSuccess(array $data) protected function redirectToSuccess(array $data)
{ {
$link = Controller::join_links( $link = Controller::join_links(
$this->link('passwordsent'), $this->Link('passwordsent'),
rawurlencode($data['Email']), rawurlencode($data['Email']),
'/' '/'
); );

View File

@ -483,7 +483,9 @@ class Security extends Controller implements TemplateGlobalProvider
public function Link($action = null) public function Link($action = null)
{ {
/** @skipUpgrade */ /** @skipUpgrade */
return Controller::join_links(Director::baseURL(), "Security", $action); $link = Controller::join_links(Director::baseURL(), "Security", $action);
$this->extend('updateLink', $link, $action);
return $link;
} }
/** /**