RouteFactory.php 601 B

1234567891011121314151617181920212223242526
  1. <?php
  2. class RouteFactory {
  3. public static function getInstance() {
  4. return new RouteFactory();
  5. }
  6. private function __construct() {
  7. }
  8. public function create(Url $url) {
  9. switch($url->getPathElement(0)) {
  10. case "dashboard":
  11. return DashboardRoute::getInstance();
  12. case "profile":
  13. return ProfileRoute::getInstance();
  14. case "login":
  15. return LoginRoute::getInstance();
  16. case "logout":
  17. return LogoutRoute::getInstance();
  18. case "install":
  19. return InstallRoute::getInstance();
  20. case "":
  21. return HomeRoute::getInstance();
  22. default:
  23. return new DefaultRoute();
  24. }
  25. }
  26. }