mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API controller::join_links supports array values
This commit is contained in:
parent
f130ebf9de
commit
92e34b7434
@ -695,12 +695,15 @@ class Controller extends RequestHandler implements TemplateGlobalProvider {
|
||||
*
|
||||
* Caution: All parameters are expected to be URI-encoded already.
|
||||
*
|
||||
* @param string
|
||||
*
|
||||
* @param string|array $arg,.. One or more link segments, or list of link segments as an array
|
||||
* @return string
|
||||
*/
|
||||
public static function join_links() {
|
||||
$args = func_get_args();
|
||||
public static function join_links($arg = null) {
|
||||
if (func_num_args() === 1 && is_array($arg)) {
|
||||
$args = $arg;
|
||||
} else {
|
||||
$args = func_get_args();
|
||||
}
|
||||
$result = "";
|
||||
$queryargs = array();
|
||||
$fragmentIdentifier = null;
|
||||
|
@ -792,6 +792,7 @@ specific functions.
|
||||
Run `composer require --dev 'phpunit/phpunit:~4.8'` on existing projects to pull in the new dependency.
|
||||
* Admin URL can now be configured via custom Director routing rule
|
||||
* `Controller::init` visibility changed to protected. Use `Controller::doInit()` instead.
|
||||
* `Controller::join_links` supports an array of link sections.
|
||||
* `Object::useCustomClass` has been removed. You should use the config API with Injector instead.
|
||||
* `Object::invokeWithExtensions` now has the same method signature as `Object::extend` and behaves the same way.
|
||||
* `ServiceConfigurationLocator` is now an interface not a class.
|
||||
|
@ -283,6 +283,11 @@ class ControllerTest extends FunctionalTest {
|
||||
|
||||
/* Does type-safe checks for zero value */
|
||||
$this->assertEquals("my-page/0", Controller::join_links("my-page", 0));
|
||||
|
||||
// Test array args
|
||||
$this->assertEquals("admin/crm/MyForm?a=1&b=2&c=3",
|
||||
Controller::join_links(["?a=1", "admin/crm", "?b=2", "MyForm?c=3"])
|
||||
);
|
||||
}
|
||||
|
||||
public function testLink() {
|
||||
|
Loading…
Reference in New Issue
Block a user