Browse Source

Rename UrlHelper::url() to UrlHelper::build().

ADmad 11 years ago
parent
commit
98788a0e54

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

@@ -304,7 +304,7 @@ class FormHelper extends Helper {
 		unset($options['templates']);
 
 		$url = $this->_formUrl($context, $options);
-		$action = $this->Url->url($url);
+		$action = $this->Url->build($url);
 		unset($options['url'], $options['action'], $options['idPrefix']);
 
 		$this->_lastAction($url);
@@ -1459,7 +1459,7 @@ class FormHelper extends Helper {
 
 		$formName = str_replace('.', '', uniqid('post_', true));
 		$formOptions = array(
-			'action' => $this->Url->url($url),
+			'action' => $this->Url->build($url),
 			'name' => $formName,
 			'style' => 'display:none;',
 			'method' => 'post',

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

@@ -314,9 +314,9 @@ class HtmlHelper extends Helper {
 	public function link($title, $url = null, array $options = array()) {
 		$escapeTitle = true;
 		if ($url !== null) {
-			$url = $this->Url->url($url);
+			$url = $this->Url->build($url);
 		} else {
-			$url = $this->Url->url($title);
+			$url = $this->Url->build($title);
 			$title = htmlspecialchars_decode($url, ENT_QUOTES);
 			$title = h(urldecode($title));
 			$escapeTitle = false;
@@ -780,7 +780,7 @@ class HtmlHelper extends Helper {
 
 		if ($url) {
 			return $this->formatTemplate('link', [
-				'url' => $this->Url->url($url),
+				'url' => $this->Url->build($url),
 				'attrs' => null,
 				'content' => $image
 			]);

+ 1 - 1
src/View/Helper/PaginatorHelper.php

@@ -433,7 +433,7 @@ class PaginatorHelper extends Helper {
 		) {
 			$url['sort'] = $url['direction'] = null;
 		}
-		return $this->Url->url($url, $full);
+		return $this->Url->build($url, $full);
 	}
 
 /**

+ 5 - 5
src/View/Helper/RssHelper.php

@@ -127,7 +127,7 @@ class RssHelper extends Helper {
 		if (!isset($elements['description'])) {
 			$elements['description'] = '';
 		}
-		$elements['link'] = $this->Url->url($elements['link'], true);
+		$elements['link'] = $this->Url->build($elements['link'], true);
 
 		$elems = '';
 		foreach ($elements as $elem => $data) {
@@ -228,14 +228,14 @@ class RssHelper extends Helper {
 						unset($attrib['url']);
 						$val = $val['url'];
 					}
-					$val = $this->Url->url($val, true);
+					$val = $this->Url->build($val, true);
 					break;
 				case 'source':
 					if (is_array($val) && isset($val['url'])) {
-						$attrib['url'] = $this->Url->url($val['url'], true);
+						$attrib['url'] = $this->Url->build($val['url'], true);
 						$val = $val['title'];
 					} elseif (is_array($val)) {
-						$attrib['url'] = $this->Url->url($val[0], true);
+						$attrib['url'] = $this->Url->build($val[0], true);
 						$val = $val[1];
 					}
 					break;
@@ -248,7 +248,7 @@ class RssHelper extends Helper {
 							$val['type'] = mime_content_type(WWW_ROOT . $val['url']);
 						}
 					}
-					$val['url'] = $this->Url->url($val['url'], true);
+					$val['url'] = $this->Url->build($val['url'], true);
 					$attrib = $val;
 					$val = null;
 					break;

+ 3 - 5
src/View/Helper/UrlHelper.php

@@ -26,9 +26,7 @@ use Cake\View\Helper;
 class UrlHelper extends Helper {
 
 /**
- * Finds URL for specified action.
- *
- * Returns a URL pointing at the provided parameters.
+ * Returns a URL based on provided provided parameters.
  *
  * @param string|array $url Either a relative string url like `/products/view/23` or
  *    an array of URL parameters. Using an array for URLs will allow you to leverage
@@ -37,7 +35,7 @@ class UrlHelper extends Helper {
  * @return string Full translated URL with base path.
  * @link http://book.cakephp.org/2.0/en/views/helpers.html
  */
-	public function url($url = null, $full = false) {
+	public function build($url = null, $full = false) {
 		return h(Router::url($url, $full));
 	}
 
@@ -55,7 +53,7 @@ class UrlHelper extends Helper {
  */
 	public function assetUrl($path, array $options = array()) {
 		if (is_array($path)) {
-			return $this->url($path, !empty($options['fullBase']));
+			return $this->build($path, !empty($options['fullBase']));
 		}
 		if (strpos($path, '://') !== false) {
 			return $path;

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

@@ -391,12 +391,12 @@ class HtmlHelperTest extends TestCase {
  */
 	public function testImageWithFullBase() {
 		$result = $this->Html->image('test.gif', array('fullBase' => true));
-		$here = $this->Html->Url->url('/', true);
+		$here = $this->Html->Url->build('/', true);
 		$expected = array('img' => array('src' => $here . 'img/test.gif', 'alt' => ''));
 		$this->assertHtml($expected, $result);
 
 		$result = $this->Html->image('sub/test.gif', array('fullBase' => true));
-		$here = $this->Html->Url->url('/', true);
+		$here = $this->Html->Url->build('/', true);
 		$expected = array('img' => array('src' => $here . 'img/sub/test.gif', 'alt' => ''));
 		$this->assertHtml($expected, $result);
 
@@ -406,7 +406,7 @@ class HtmlHelperTest extends TestCase {
 		Router::pushRequest($request);
 
 		$result = $this->Html->image('sub/test.gif', array('fullBase' => true));
-		$here = $this->Html->Url->url('/', true);
+		$here = $this->Html->Url->build('/', true);
 		$expected = array('img' => array('src' => $here . 'img/sub/test.gif', 'alt' => ''));
 		$this->assertHtml($expected, $result);
 	}
@@ -619,7 +619,7 @@ class HtmlHelperTest extends TestCase {
  */
 	public function testCssWithFullBase() {
 		Configure::write('Asset.filter.css', false);
-		$here = $this->Html->Url->url('/', true);
+		$here = $this->Html->Url->build('/', true);
 
 		$result = $this->Html->css('screen', array('fullBase' => true));
 		$expected = array(
@@ -994,7 +994,7 @@ class HtmlHelperTest extends TestCase {
  * @return void
  */
 	public function testScriptWithFullBase() {
-		$here = $this->Html->Url->url('/', true);
+		$here = $this->Html->Url->build('/', true);
 
 		$result = $this->Html->script('foo', array('fullBase' => true));
 		$expected = array(

+ 3 - 3
tests/TestCase/View/Helper/RssHelperTest.php

@@ -104,7 +104,7 @@ class RssHelperTest extends TestCase {
 			'Title',
 			'/title',
 			'<link',
-			$this->Rss->Url->url('/', true),
+			$this->Rss->Url->build('/', true),
 			'/link',
 			'<description',
 			'content',
@@ -551,7 +551,7 @@ class RssHelperTest extends TestCase {
 			'<description',
 			'<![CDATA[descriptive words]]',
 			'/description',
-			'enclosure' => array('url' => $this->Rss->Url->url('/test.flv', true)),
+			'enclosure' => array('url' => $this->Rss->Url->build('/test.flv', true)),
 			'<pubDate',
 			date('r', strtotime('2008-05-31 12:00:00')),
 			'/pubDate',
@@ -633,7 +633,7 @@ class RssHelperTest extends TestCase {
 			'<![CDATA[descriptive words]]',
 			'/description',
 			'enclosure' => array(
-				'url' => $this->Rss->Url->url('/tests/cakephp.file.test.tmp', true),
+				'url' => $this->Rss->Url->build('/tests/cakephp.file.test.tmp', true),
 				'length' => filesize($tmpFile),
 				'type' => $type
 			),

+ 8 - 8
tests/TestCase/View/Helper/UrlHelperTest.php

@@ -66,30 +66,30 @@ class HelperTest extends TestCase {
 	public function testUrlConversion() {
 		Router::connect('/:controller/:action/*');
 
-		$result = $this->Helper->url('/controller/action/1');
+		$result = $this->Helper->build('/controller/action/1');
 		$this->assertEquals('/controller/action/1', $result);
 
-		$result = $this->Helper->url('/controller/action/1?one=1&two=2');
+		$result = $this->Helper->build('/controller/action/1?one=1&two=2');
 		$this->assertEquals('/controller/action/1?one=1&amp;two=2', $result);
 
-		$result = $this->Helper->url(array('controller' => 'posts', 'action' => 'index', 'page' => '1" onclick="alert(\'XSS\');"'));
+		$result = $this->Helper->build(array('controller' => 'posts', 'action' => 'index', 'page' => '1" onclick="alert(\'XSS\');"'));
 		$this->assertEquals("/posts/index?page=1%22+onclick%3D%22alert%28%27XSS%27%29%3B%22", $result);
 
-		$result = $this->Helper->url('/controller/action/1/param:this+one+more');
+		$result = $this->Helper->build('/controller/action/1/param:this+one+more');
 		$this->assertEquals('/controller/action/1/param:this+one+more', $result);
 
-		$result = $this->Helper->url('/controller/action/1/param:this%20one%20more');
+		$result = $this->Helper->build('/controller/action/1/param:this%20one%20more');
 		$this->assertEquals('/controller/action/1/param:this%20one%20more', $result);
 
-		$result = $this->Helper->url('/controller/action/1/param:%7Baround%20here%7D%5Bthings%5D%5Bare%5D%24%24');
+		$result = $this->Helper->build('/controller/action/1/param:%7Baround%20here%7D%5Bthings%5D%5Bare%5D%24%24');
 		$this->assertEquals('/controller/action/1/param:%7Baround%20here%7D%5Bthings%5D%5Bare%5D%24%24', $result);
 
-		$result = $this->Helper->url(array(
+		$result = $this->Helper->build(array(
 			'controller' => 'posts', 'action' => 'index', 'param' => '%7Baround%20here%7D%5Bthings%5D%5Bare%5D%24%24'
 		));
 		$this->assertEquals("/posts/index?param=%257Baround%2520here%257D%255Bthings%255D%255Bare%255D%2524%2524", $result);
 
-		$result = $this->Helper->url(array(
+		$result = $this->Helper->build(array(
 			'controller' => 'posts', 'action' => 'index', 'page' => '1',
 			'?' => array('one' => 'value', 'two' => 'value', 'three' => 'purple')
 		));