PageRenderTime 53ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/app/Controller/PagesController.php

https://gitlab.com/fouzia23chowdhury/cakephpCRUD
PHP | 76 lines | 31 code | 7 blank | 38 comment | 5 complexity | 2aade6697b12e3ae10dab0af59a08537 MD5 | raw file
  1. <?php
  2. /**
  3. * Static content controller.
  4. *
  5. * This file will render views from views/pages/
  6. *
  7. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  8. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  9. *
  10. * Licensed under The MIT License
  11. * For full copyright and license information, please see the LICENSE.txt
  12. * Redistributions of files must retain the above copyright notice.
  13. *
  14. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  15. * @link http://cakephp.org CakePHP(tm) Project
  16. * @package app.Controller
  17. * @since CakePHP(tm) v 0.2.9
  18. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  19. */
  20. App::uses('AppController', 'Controller');
  21. /**
  22. * Static content controller
  23. *
  24. * Override this controller by placing a copy in controllers directory of an application
  25. *
  26. * @package app.Controller
  27. * @link http://book.cakephp.org/2.0/en/controllers/pages-controller.html
  28. */
  29. class PagesController extends AppController {
  30. /**
  31. * This controller does not use a model
  32. *
  33. * @var array
  34. */
  35. public $uses = array();
  36. /**
  37. * Displays a view
  38. *
  39. * @return void
  40. * @throws NotFoundException When the view file could not be found
  41. * or MissingViewException in debug mode.
  42. */
  43. public function display() {
  44. $path = func_get_args();
  45. $count = count($path);
  46. if (!$count) {
  47. return $this->redirect('/');
  48. }
  49. $page = $subpage = $title_for_layout = null;
  50. if (!empty($path[0])) {
  51. $page = $path[0];
  52. }
  53. if (!empty($path[1])) {
  54. $subpage = $path[1];
  55. }
  56. if (!empty($path[$count - 1])) {
  57. $title_for_layout = Inflector::humanize($path[$count - 1]);
  58. }
  59. $this->set(compact('page', 'subpage', 'title_for_layout'));
  60. try {
  61. $this->render(implode('/', $path));
  62. } catch (MissingViewException $e) {
  63. if (Configure::read('debug')) {
  64. throw $e;
  65. }
  66. throw new NotFoundException();
  67. }
  68. }
  69. }