PageRenderTime 46ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/Croogo/View/Helper/CroogoAppHelper.php

https://github.com/kareypowell/croogo
PHP | 53 lines | 23 code | 5 blank | 25 comment | 5 complexity | 82bc1b9e3cef2ba0495804998abe2af5 MD5 | raw file
  1. <?php
  2. App::uses('Helper', 'View');
  3. /**
  4. * Croogo Application helper
  5. *
  6. * @category Helpers
  7. * @package Croogo.Croogo.View.Helper
  8. * @version 1.0
  9. * @author Fahad Ibnay Heylaal <contact@fahad19.com>
  10. * @license http://www.opensource.org/licenses/mit-license.php The MIT License
  11. * @link http://www.croogo.org
  12. */
  13. class CroogoAppHelper extends Helper {
  14. /**
  15. * Url helper function
  16. *
  17. * @param string $url
  18. * @param bool $full
  19. * @return mixed
  20. * @access public
  21. */
  22. public function url($url = null, $full = false) {
  23. if (isset($this->request->params['locale'])) {
  24. if ($url === null || (is_array($url) && !isset($url['locale']))) {
  25. $url['locale'] = $this->request->params['locale'];
  26. }
  27. }
  28. return parent::url($url, $full);
  29. }
  30. /**
  31. * Convenience method to generate an API Url
  32. *
  33. * @param string|array $url
  34. * @param bool $full
  35. * @return string
  36. */
  37. public function apiUrl($url = null, $full = false) {
  38. if (is_array($url)) {
  39. $url = Hash::merge(array(
  40. 'admin' => false,
  41. 'api' => Configure::read('Croogo.Api.path'),
  42. 'prefix' => 'v1.0',
  43. 'ext' => 'json',
  44. ), $url);
  45. }
  46. return parent::url($url, $full);
  47. }
  48. }