UrlHelper.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * For full copyright and license information, please see the LICENSE.txt
  8. * Redistributions of files must retain the above copyright notice.
  9. *
  10. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  11. * @link http://cakephp.org CakePHP(tm) Project
  12. * @since 0.9.1
  13. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  14. */
  15. namespace Tools\View\Helper;
  16. use Cake\Core\Configure;
  17. use Cake\Network\Response;
  18. use Cake\View\Helper\UrlHelper as CoreUrlHelper;
  19. use Cake\View\StringTemplateTrait;
  20. use Cake\View\View;
  21. /**
  22. * Url Helper class.
  23. */
  24. class UrlHelper extends CoreUrlHelper {
  25. /**
  26. * @deprecated
  27. */
  28. public function defaultBuild($url = null, $full = false) {
  29. return $this->reset($url, $full);
  30. }
  31. /**
  32. * Creates a reset URL.
  33. * The prefix and plugin params are resetting to default false.
  34. *
  35. * @param string|array $url URL.
  36. * @param bool $full If true, the full base URL will be prepended to the result
  37. * @return string Full translated URL with base path.
  38. */
  39. public function reset($url = null, $full = false) {
  40. if (is_array($url)) {
  41. $url += ['prefix' => false, 'plugin' => false];
  42. }
  43. return parent::build($url, $full);
  44. }
  45. /**
  46. * Returns a URL based on provided parameters.
  47. *
  48. * @param string|array $url URL.
  49. * @param bool $full If true, the full base URL will be prepended to the result
  50. * @return string Full translated URL with base path.
  51. */
  52. public function complete($url = null, $full = false) {
  53. if (is_array($url)) {
  54. // Add query strings
  55. if (!isset($url['?'])) {
  56. $url['?'] = [];
  57. }
  58. $url['?'] += $this->request->query;
  59. }
  60. return parent::build($url, $full);
  61. }
  62. /**
  63. * Event listeners.
  64. *
  65. * @return array
  66. */
  67. public function implementedEvents()
  68. {
  69. return [];
  70. }
  71. }