AController.php 744 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace Tools;
  3. /**
  4. * Controller abstract class
  5. **/
  6. abstract class AController
  7. {
  8. /**
  9. * @var array $params
  10. * Contains route parameter
  11. * ex: /product/:id will contains {
  12. * 0 => product
  13. * 1 => [ID]
  14. * ':id' => [ID]
  15. **/
  16. protected $params;
  17. /**
  18. * @var \Tools\Context $context
  19. **/
  20. protected $context;
  21. /**
  22. * @param \Tools\Context $context
  23. * @param array $params
  24. * @throws \Exception\Error404 if parameters does not correspond
  25. * On 404 error, router will try to find another route
  26. * Initialize structure
  27. **/
  28. public function __construct($context, $params)
  29. {
  30. $this->params = $params;
  31. $this->context = $context;
  32. }
  33. /**
  34. * Fullfill Controller's request
  35. **/
  36. public abstract function start();
  37. }