mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API CHANGE #3724: Unified the Link() method to accept an action parameter.
From: Andrew Short <andrewjshort@gmail.com> git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@88495 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
c1c7973b95
commit
f29eceecff
@ -158,10 +158,11 @@ class RSSFeed extends ViewableData {
|
|||||||
/**
|
/**
|
||||||
* Get the URL of this feed
|
* Get the URL of this feed
|
||||||
*
|
*
|
||||||
|
* @param string $action
|
||||||
* @return string Returns the URL of the feed.
|
* @return string Returns the URL of the feed.
|
||||||
*/
|
*/
|
||||||
function Link() {
|
function Link($action = null) {
|
||||||
return Director::absoluteURL($this->link);
|
return Controller::join_links(Director::absoluteURL($this->link), $action);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,8 +67,8 @@ class SOAPModelAccess extends SapphireSoapServer {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
function Link() {
|
function Link($action = null) {
|
||||||
return "soap/v1/";
|
return Controller::join_links("soap/v1/", $action);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -404,13 +404,6 @@ class Controller extends RequestHandler {
|
|||||||
return $d;
|
return $d;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an absolute link to this controller
|
|
||||||
*/
|
|
||||||
function AbsoluteLink() {
|
|
||||||
return Director::absoluteURL($this->Link());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the currently logged in user
|
* Returns the currently logged in user
|
||||||
*/
|
*/
|
||||||
|
@ -51,8 +51,8 @@ class RedirectorPage extends Page {
|
|||||||
* Return the normal link directly to this page. Once you visit this link, a 30x redirection
|
* Return the normal link directly to this page. Once you visit this link, a 30x redirection
|
||||||
* will take you to your final destination.
|
* will take you to your final destination.
|
||||||
*/
|
*/
|
||||||
function regularLink() {
|
function regularLink($action = null) {
|
||||||
return parent::Link();
|
return parent::Link($action);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -682,8 +682,8 @@ class ComplexTableField_ItemRequest extends RequestHandler {
|
|||||||
'' => 'index',
|
'' => 'index',
|
||||||
);
|
);
|
||||||
|
|
||||||
function Link() {
|
function Link($action = null) {
|
||||||
return $this->ctf->Link() . '/item/' . $this->itemID;
|
return Controller::join_links($this->ctf->Link(), '/item/', $this->itemID, $action);
|
||||||
}
|
}
|
||||||
|
|
||||||
function __construct($ctf, $itemID) {
|
function __construct($ctf, $itemID) {
|
||||||
@ -997,8 +997,8 @@ class ComplexTableField_Item extends TableListField_Item {
|
|||||||
parent::__construct($item, $parent);
|
parent::__construct($item, $parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Link() {
|
function Link($action = null) {
|
||||||
return $this->parent->Link() . '/item/' . $this->item->ID;
|
return Controller::join_links($this->parent->Link(), '/item/', $this->item->ID, $action);
|
||||||
}
|
}
|
||||||
|
|
||||||
function EditLink() {
|
function EditLink() {
|
||||||
|
@ -84,8 +84,8 @@ class FormField extends RequestHandler {
|
|||||||
/**
|
/**
|
||||||
* Return a Link to this field
|
* Return a Link to this field
|
||||||
*/
|
*/
|
||||||
function Link() {
|
function Link($action = null) {
|
||||||
return Controller::join_links($this->form->FormAction(), 'field/' . $this->name);
|
return Controller::join_links($this->form->FormAction(), 'field/' . $this->name, $action);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1318,11 +1318,11 @@ class TableListField_Item extends ViewableData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Link() {
|
function Link($action = null) {
|
||||||
if($this->parent->getForm()) {
|
if($this->parent->getForm()) {
|
||||||
$parentUrlParts = parse_url($this->parent->Link());
|
$parentUrlParts = parse_url($this->parent->Link());
|
||||||
$queryPart = (isset($parentUrlParts['query'])) ? '?' . $parentUrlParts['query'] : null;
|
$queryPart = (isset($parentUrlParts['query'])) ? '?' . $parentUrlParts['query'] : null;
|
||||||
return Controller::join_links($parentUrlParts['path'], 'item', $this->item->ID, $queryPart);
|
return Controller::join_links($parentUrlParts['path'], 'item', $this->item->ID, $action, $queryPart);
|
||||||
} else {
|
} else {
|
||||||
// allow for instanciation of this FormField outside of a controller/form
|
// allow for instanciation of this FormField outside of a controller/form
|
||||||
// context (e.g. for unit tests)
|
// context (e.g. for unit tests)
|
||||||
|
4
tests/api/RSSFeedTest.php
Normal file → Executable file
4
tests/api/RSSFeedTest.php
Normal file → Executable file
@ -67,8 +67,8 @@ class RSSFeedTest_ItemA extends ViewableData {
|
|||||||
return "ItemA AltContent";
|
return "ItemA AltContent";
|
||||||
}
|
}
|
||||||
|
|
||||||
function Link() {
|
function Link($action = null) {
|
||||||
return "item-a/";
|
return Controller::join_links("item-a/", $action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
tests/forms/FormTest.php
Normal file → Executable file
4
tests/forms/FormTest.php
Normal file → Executable file
@ -284,8 +284,8 @@ class FormTest_Controller extends Controller {
|
|||||||
|
|
||||||
protected $template = 'BlankPage';
|
protected $template = 'BlankPage';
|
||||||
|
|
||||||
function Link() {
|
function Link($action = null) {
|
||||||
return Controller::join_links('FormTest_Controller', $this->request->latestParam('Action'), $this->request->latestParam('ID'));
|
return Controller::join_links('FormTest_Controller', $this->request->latestParam('Action'), $this->request->latestParam('ID'), $action);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Form() {
|
function Form() {
|
||||||
|
5
tests/forms/TableFieldTest.php
Normal file → Executable file
5
tests/forms/TableFieldTest.php
Normal file → Executable file
@ -284,11 +284,10 @@ class TableFieldTest extends SapphireTest {
|
|||||||
* Stub controller
|
* Stub controller
|
||||||
*/
|
*/
|
||||||
class TableFieldTest_Controller extends Controller {
|
class TableFieldTest_Controller extends Controller {
|
||||||
function Link() {
|
function Link($action = null) {
|
||||||
return 'TableFieldTest/';
|
return Controller::join_links('TableFieldTest/', $action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TableFieldTest_Object extends DataObject implements TestOnly {
|
class TableFieldTest_Object extends DataObject implements TestOnly {
|
||||||
static $has_many = array(
|
static $has_many = array(
|
||||||
"HasManyRelations" => 'TableFieldTest_HasManyRelation'
|
"HasManyRelations" => 'TableFieldTest_HasManyRelation'
|
||||||
|
4
tests/forms/TableListFieldTest.php
Normal file → Executable file
4
tests/forms/TableListFieldTest.php
Normal file → Executable file
@ -206,8 +206,8 @@ class TableListFieldTest_CsvExport extends DataObject implements TestOnly {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class TableListFieldTest_TestController extends Controller {
|
class TableListFieldTest_TestController extends Controller {
|
||||||
function Link() {
|
function Link($action = null) {
|
||||||
return "TableListFieldTest_TestController/";
|
return Controller::join_links("TableListFieldTest_TestController/", $action);
|
||||||
}
|
}
|
||||||
function TestForm() {
|
function TestForm() {
|
||||||
$table = new TableListField("Table", "TableListFieldTest_Obj", array(
|
$table = new TableListField("Table", "TableListFieldTest_Obj", array(
|
||||||
|
8
widgets/Widget.php
Normal file → Executable file
8
widgets/Widget.php
Normal file → Executable file
@ -154,11 +154,9 @@ class Widget_Controller extends Controller {
|
|||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
function Link() {
|
public function Link($action = null) {
|
||||||
return Controller::join_links(
|
return Controller::curr()->Link (
|
||||||
Controller::curr()->Link(),
|
Controller::join_links('widget', ($this->widget ? $this->widget->ID : null), $action)
|
||||||
'widget',
|
|
||||||
($this->widget) ? $this->widget->ID : null
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user