mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #5854 from open-sausages/pulls/4.0/controller-link-standardise
API Add $action parameter to Controller::Link
This commit is contained in:
commit
18465e783f
@ -127,10 +127,11 @@ class Controller extends RequestHandler implements TemplateGlobalProvider {
|
||||
/**
|
||||
* Returns a link to this controller. Overload with your own Link rules if they exist.
|
||||
*
|
||||
* @param string $action Optional action
|
||||
* @return string
|
||||
*/
|
||||
public function Link() {
|
||||
return get_class($this) .'/';
|
||||
public function Link($action = null) {
|
||||
return Controller::join_links(get_class($this), $action, '/');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,6 +56,7 @@
|
||||
* `CMSMain::buildbrokenlinks()` action is removed.
|
||||
* `Folder_UnusedAssetsField` is removed.
|
||||
* `UpgradeSiteTreePermissionSchemaTask` is removed.
|
||||
* `$action` parameter to `Controller::Link()` method is standardised.
|
||||
|
||||
## New API
|
||||
|
||||
|
@ -273,6 +273,14 @@ class ControllerTest extends FunctionalTest {
|
||||
$this->assertEquals("my-page/0", Controller::join_links("my-page", 0));
|
||||
}
|
||||
|
||||
public function testLink() {
|
||||
$controller = new ControllerTest_HasAction();
|
||||
$this->assertEquals('ControllerTest_HasAction/', $controller->Link());
|
||||
$this->assertEquals('ControllerTest_HasAction/', $controller->Link(null));
|
||||
$this->assertEquals('ControllerTest_HasAction/', $controller->Link(false));
|
||||
$this->assertEquals('ControllerTest_HasAction/allowed-action/', $controller->Link('allowed-action'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Controller::hasAction
|
||||
*/
|
||||
|
@ -118,8 +118,8 @@ class MemberDatetimeOptionsetFieldTest extends SapphireTest {
|
||||
}
|
||||
class MemberDatetimeOptionsetFieldTest_Controller extends Controller {
|
||||
|
||||
public function Link() {
|
||||
return 'test';
|
||||
public function Link($action = null) {
|
||||
return Controller::join_links('test', $action, '/');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,9 +35,6 @@ class GridField_URLHandlerTest_Controller extends Controller implements TestOnly
|
||||
|
||||
private static $allowed_actions = array('Form');
|
||||
|
||||
public function Link() {
|
||||
return get_class($this) ."/";
|
||||
}
|
||||
public function Form() {
|
||||
$gridConfig = GridFieldConfig::create();
|
||||
$gridConfig->addComponent(new GridField_URLHandlerTest_Component());
|
||||
|
Loading…
Reference in New Issue
Block a user