Base
This commit is contained in:
31
app/Definition/Controller.php
Normal file
31
app/Definition/Controller.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
namespace App\Definition;
|
||||
|
||||
trait Controller
|
||||
{
|
||||
protected static $default;
|
||||
|
||||
public static function index()
|
||||
{
|
||||
$action = get('a');
|
||||
if ($action == null) {
|
||||
$action = get('action');
|
||||
}
|
||||
if ($action != null) {
|
||||
$ref = new \ReflectionMethod(self::class, $action);
|
||||
if (method_exists(self::class, $action) and $ref->isPublic()) {
|
||||
|
||||
return self::{$action}();
|
||||
}
|
||||
}
|
||||
if (self::$default == null and \method_exists(self::class, 'setDefault')) {
|
||||
self::setDefault();
|
||||
}
|
||||
if (self::$default == null) {
|
||||
header('Location: .');
|
||||
return;
|
||||
}
|
||||
return self::$default;
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user