Browse Source

Fix up linkReset and linkComplete to be consistent with the rest of the API

dereuromark 9 years ago
parent
commit
5e99e247f7

+ 4 - 4
docs/Helper/Html.md

@@ -2,7 +2,7 @@
 
 An enhanced HtmlHelper
 - imageFromBlob()
-- resetLink() and completeLink()
+- linkReset() and linkComplete()
 
 ## Usage
 Attach it to your controllers like so:
@@ -31,15 +31,15 @@ This is especially important with navigation menu or layout elements, as those w
 
 You can then either manually and verbosely always set both to `false`, or just use the convenience method:
 ```php
-echo $this->Html->resetLink(['controller' => 'Foo', 'action' => 'bar']);
+echo $this->Html->linkReset(['controller' => 'Foo', 'action' => 'bar']);
 ```
 
 Inside `/admin/plugin-name/example/action` the linked URL would normally become `/admin/plugin-name/foo/bar`.
-With the resetLink() method it will become the desired: `/foo/bar`.
+With the linkReset() method it will become the desired: `/foo/bar`.
 
 In both cases, however, the query strings are not passed on. If you want that, you can use the other convenience method:
 ```php
-echo $this->Html->completeLink(['controller' => 'Foo', 'action' => 'bar']);
+echo $this->Html->linkComplete(['controller' => 'Foo', 'action' => 'bar']);
 ```
 Now if there was a query string `?q=x` on the current action, it would also be passed along as `/foo/bar?q=x`.
 

+ 2 - 2
docs/Url/Url.md

@@ -14,7 +14,7 @@ It will basically add in `'prefix' => false, 'plugin' => false`.
 ### Reset
 You can in that case also just use the convenience method:
 ```php
-$url = $this->Url->reset(['controller' => 'Main', 'action' => 'overview']);
+$url = $this->Url->buildReset(['controller' => 'Main', 'action' => 'overview']);
 ```
 
 In case you just want the array (to pass it on), use:
@@ -32,7 +32,7 @@ For the controller
 ### Complete
 In both cases, however, the query strings are not passed on. If you want that, you can use the other convenience method:
 ```php
-$url = $this->Url->complete(['controller' => 'Main', 'action' => 'overview']);
+$url = $this->Url->buildComplete(['controller' => 'Main', 'action' => 'overview']);
 ```
 
 In case you just want the array (to pass it on), use:

+ 2 - 2
src/View/Helper/HtmlHelper.php

@@ -66,7 +66,7 @@ class HtmlHelper extends CoreHtmlHelper {
 	 * @param array $options Array of options and HTML attributes.
 	 * @return string An `<a />` element.
 	 */
-	public function resetLink($title, $url = null, array $options = []) {
+	public function linkReset($title, $url = null, array $options = []) {
 		if (is_array($url)) {
 			$url += ['prefix' => false, 'plugin' => false];
 		}
@@ -91,7 +91,7 @@ class HtmlHelper extends CoreHtmlHelper {
 	 * @return string An `<a />` element.
 	 * @return string Link
 	 */
-	public function completeLink($title, $url = null, array $options = []) {
+	public function linkComplete($title, $url = null, array $options = []) {
 		if (is_array($url)) {
 			// Add query strings
 			if (!isset($url['?'])) {

+ 6 - 6
tests/TestCase/View/Helper/HtmlHelperTest.php

@@ -45,10 +45,10 @@ class HtmlHelperTest extends TestCase {
 	 *
 	 * @return void
 	 */
-	public function testResetLink() {
+	public function testLinkReset() {
 		Router::connect('/:controller/:action/*');
 
-		$result = $this->Html->resetLink('Foo', ['controller' => 'foobar', 'action' => 'test']);
+		$result = $this->Html->linkReset('Foo', ['controller' => 'foobar', 'action' => 'test']);
 		$expected = '<a href="/foobar/test">Foo</a>';
 		$this->assertEquals($expected, $result);
 
@@ -70,7 +70,7 @@ class HtmlHelperTest extends TestCase {
 		//debug($result);
 		//$this->assertEquals($expected, $result);
 
-		$result = $this->Html->resetLink('Foo', ['controller' => 'foobar', 'action' => 'test']);
+		$result = $this->Html->linkReset('Foo', ['controller' => 'foobar', 'action' => 'test']);
 		$expected = '<a href="/foobar/test">Foo</a>';
 		$this->assertEquals($expected, $result);
 	}
@@ -80,14 +80,14 @@ class HtmlHelperTest extends TestCase {
 	 *
 	 * @return void
 	 */
-	public function testCompleteLink() {
+	public function testLinkComplete() {
 		$this->Html->request->query['x'] = 'y';
 
-		$result = $this->Html->completeLink('Foo', ['action' => 'test']);
+		$result = $this->Html->linkComplete('Foo', ['action' => 'test']);
 		$expected = '<a href="/test?x=y">Foo</a>';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Html->completeLink('Foo', ['action' => 'test', '?' => ['a' => 'b']]);
+		$result = $this->Html->linkComplete('Foo', ['action' => 'test', '?' => ['a' => 'b']]);
 		$expected = '<a href="/test?a=b&amp;x=y">Foo</a>';
 		$this->assertEquals($expected, $result);
 	}