HomeController.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace Apps\Controllers;
  3. use Cygnite\Foundation\Application;
  4. use Cygnite\Mvc\Controller\AbstractBaseController;
  5. class HomeController extends AbstractBaseController
  6. {
  7. /**
  8. * --------------------------------------------------------------------------
  9. * The Default Controller
  10. *--------------------------------------------------------------------------
  11. * This controller respond to uri beginning with home and also
  12. * respond to root url like "home/index"
  13. *
  14. * Your GET request of "home/index" will respond like below -
  15. *
  16. * public function indexAction()
  17. * {
  18. * echo "Cygnite : Hellow ! World ";
  19. * }
  20. * Note: By default cygnite doesn't allow you to pass query string in url, which
  21. * consider as bad url format.
  22. *
  23. * You can also pass parameters into the function as below-
  24. * Your request to "home/form/2134" will pass to
  25. *
  26. * public function formAction($id = ")
  27. * {
  28. * echo "Cygnite : Your user Id is $id";
  29. * }
  30. * In case if you are not able to access parameters passed into method
  31. * directly as above, you can also get the uri segment
  32. * echo Url::segment(3);
  33. *
  34. * That's it you are ready to start your awesome application with Cygnite Framework.
  35. *
  36. */
  37. protected $layout = 'layout.home';
  38. protected $templateEngine = false;
  39. // protected $templateExtension = '.html.twig';
  40. //protected $autoReload = true;
  41. /*
  42. * Your constructor.
  43. * @access public
  44. *
  45. */
  46. public function __construct()
  47. {
  48. parent::__construct();
  49. }
  50. /**
  51. * Default method for your controller. Render welcome page to user.
  52. * @access public
  53. *
  54. */
  55. public function indexAction()
  56. {
  57. $this->render('welcome', array('title' => 'Welcome to Cygnite Framework'));
  58. }
  59. public function hmvcAction($id)
  60. {
  61. //We are calling HMVC widget and return response
  62. $widgetResponse = $this->call('modules.admin.controllers.user@index', array('id' => $id));
  63. //You should enable layout in order to access variable into view page
  64. $this->render('application', array(
  65. 'messege' => 'Welcome to Cygnite framework',
  66. 'userwidget' => $widgetResponse
  67. ));
  68. }
  69. }//End of your home controller