|
|
@@ -14,25 +14,21 @@ use Shim\Controller\Component\Component;
|
|
|
class UrlComponent extends Component {
|
|
|
|
|
|
/**
|
|
|
- * Returns a URL based on provided parameters.
|
|
|
- *
|
|
|
- * ### Options:
|
|
|
- *
|
|
|
- * - `fullBase`: If true, the full base URL will be prepended to the result
|
|
|
- *
|
|
|
- * @param string|array|null $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
|
|
|
- * the reverse routing features of CakePHP.
|
|
|
- * @param array $options Array of options
|
|
|
- * @return string Full translated URL with base path.
|
|
|
+ * @param array $url
|
|
|
+ * @return array
|
|
|
*/
|
|
|
- public function build($url = null, array $options = []) {
|
|
|
- $defaults = [
|
|
|
- 'fullBase' => false,
|
|
|
- ];
|
|
|
- $options += $defaults;
|
|
|
+ public function resetArray(array $url) {
|
|
|
+ $url += $this->defaults();
|
|
|
|
|
|
- $url = Router::url($url, $options['fullBase']);
|
|
|
+ return $url;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param array $url
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function completeArray(array $url) {
|
|
|
+ $url = $this->addQueryStrings($url);
|
|
|
|
|
|
return $url;
|
|
|
}
|
|
|
@@ -56,6 +52,23 @@ class UrlComponent extends Component {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Returns a URL based on provided parameters.
|
|
|
+ *
|
|
|
+ * Can only add query strings for array URLs.
|
|
|
+ *
|
|
|
+ * @param string|array|null $url URL.
|
|
|
+ * @param bool $full If true, the full base URL will be prepended to the result
|
|
|
+ * @return string Full translated URL with base path.
|
|
|
+ */
|
|
|
+ public function complete($url = null, $full = false) {
|
|
|
+ if (is_array($url)) {
|
|
|
+ $url = $this->addQueryStrings($url);
|
|
|
+ }
|
|
|
+
|
|
|
+ return Router::url($url, $full);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* @return array
|
|
|
*/
|
|
|
public function defaults() {
|
|
|
@@ -68,18 +81,25 @@ class UrlComponent extends Component {
|
|
|
/**
|
|
|
* Returns a URL based on provided parameters.
|
|
|
*
|
|
|
- * Can only add query strings for array URLs.
|
|
|
+ * ### Options:
|
|
|
*
|
|
|
- * @param string|array|null $url URL.
|
|
|
- * @param bool $full If true, the full base URL will be prepended to the result
|
|
|
+ * - `fullBase`: If true, the full base URL will be prepended to the result
|
|
|
+ *
|
|
|
+ * @param string|array|null $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
|
|
|
+ * the reverse routing features of CakePHP.
|
|
|
+ * @param array $options Array of options
|
|
|
* @return string Full translated URL with base path.
|
|
|
*/
|
|
|
- public function complete($url = null, $full = false) {
|
|
|
- if (is_array($url)) {
|
|
|
- $url = $this->addQueryStrings($url);
|
|
|
- }
|
|
|
+ public function build($url = null, array $options = []) {
|
|
|
+ $defaults = [
|
|
|
+ 'fullBase' => false,
|
|
|
+ ];
|
|
|
+ $options += $defaults;
|
|
|
|
|
|
- return Router::url($url, $full);
|
|
|
+ $url = Router::url($url, $options['fullBase']);
|
|
|
+
|
|
|
+ return $url;
|
|
|
}
|
|
|
|
|
|
/**
|