HomeRoute.php 686 B

12345678910111213141516171819202122232425
  1. <?php
  2. class HomeRoute implements IRoute {
  3. public static function getInstance() {
  4. return new HomeRoute(new View(), Authorizer::getInstance(), new HeaderWrapper());
  5. }
  6. private $view;
  7. private $authorizer;
  8. private $header;
  9. private function __construct(View $view, Authorizer $authorizer, HeaderWrapper $header) {
  10. $this->view = $view;
  11. $this->authorizer = $authorizer;
  12. $this->header = $header;
  13. }
  14. public function run(Url $url) {
  15. if($this->authorizer->isLoggedIn()) {
  16. $this->header->location("/dashboard");
  17. }
  18. $viewData = array(
  19. "url" => $url,
  20. "isLoggedIn" => false,
  21. "title" => "Browser Game"
  22. );
  23. return $this->view->render("homeView.php", $viewData);
  24. }
  25. }