controller.abstract.class.php 663 B

1234567891011121314151617181920212223242526
  1. <?php
  2. namespace Juju\App;
  3. require_once('router.class.php');
  4. abstract class Controller {
  5. private $name;
  6. public abstract static function handle(Router $router);
  7. public static function controllers(){
  8. return array_filter(get_declared_classes(), function($class){
  9. return 0 === strpos($class, "Controller\\");
  10. });
  11. }
  12. public static function handle_all(Router $router){
  13. foreach(self::controllers() as $controller){
  14. $controller::handle($router);
  15. }
  16. }
  17. public static function name(){
  18. if(is_null(static::$name)){
  19. $name = get_called_class();
  20. return substr($name, strrpos($name, '\\') + 1);
  21. }
  22. return static::$name;
  23. }
  24. }
  25. ?>