61 lines
2.5 KiB
PHP
61 lines
2.5 KiB
PHP
<?php
|
|
|
|
|
|
namespace kernel;
|
|
|
|
|
|
use Phroute\Phroute\Route;
|
|
use Phroute\Phroute\RouteCollector;
|
|
|
|
class CgRouteCollector extends RouteCollector
|
|
{
|
|
public function crud($route, $handler, array $filters = []): CgRouteCollector
|
|
{
|
|
$this->addRoute(Route::GET, $route, array_merge($handler, ['actionIndex']), $filters);
|
|
$this->addRoute(Route::GET, $route . '/{id}', array_merge($handler, ['actionView']), $filters);
|
|
$this->addRoute(Route::POST, $route, array_merge($handler, ['actionStore']), $filters);
|
|
$this->addRoute(Route::DELETE, $route, array_merge($handler, ['actionDelete']), $filters);
|
|
return $this->addRoute(Route::ANY, $route . '/update/{id}', array_merge($handler, ['actionEdit']), $filters);
|
|
}
|
|
|
|
public function gridView($route, $handler, array $filters = []): CgRouteCollector
|
|
{
|
|
$this->addRoute(Route::GET, $route, array_merge($handler, ['actionIndex']), $filters);
|
|
$this->addRoute(Route::GET, $route . '/{id}', array_merge($handler, ['actionView']), $filters);
|
|
$this->addRoute(Route::ANY, $route . '/create', array_merge($handler, ['actionStore']), $filters);
|
|
$this->addRoute(Route::POST, $route . '/delete', array_merge($handler, ['actionDelete']), $filters);
|
|
return $this->addRoute(Route::ANY, $route . '/update/{id}', array_merge($handler, ['actionEdit']), $filters);
|
|
}
|
|
|
|
public function rest($route, $handler, array $filters = []): CgRouteCollector
|
|
{
|
|
$this->addRoute(Route::GET, $route, array_merge($handler, ['actionIndex']), $filters);
|
|
$this->addRoute(Route::GET, $route . '/{id}', array_merge($handler, ['actionView']), $filters);
|
|
$this->addRoute(Route::POST, $route . '/', array_merge($handler, ['actionStore']), $filters);
|
|
$this->addRoute(Route::DELETE, $route . '/delete', array_merge($handler, ['actionDelete']), $filters);
|
|
return $this->addRoute(Route::ANY, $route . '/update/{id}', array_merge($handler, ['actionEdit']), $filters);
|
|
}
|
|
|
|
public function authorization($route, $handler, array $filters = [])
|
|
{
|
|
//TODO
|
|
}
|
|
|
|
public function exclude($action)
|
|
{
|
|
//TODO
|
|
}
|
|
|
|
/**
|
|
* @param $route
|
|
* @param $handler
|
|
* @param array $filters
|
|
* @param array $additionalInfo
|
|
* @return void
|
|
*/
|
|
public function console($route, $handler, array $filters = [], array $additionalInfo = []): void
|
|
{
|
|
$additionalInfo['type'] = "console";
|
|
$this->addRoute(Route::GET, $route, $handler, $filters, $additionalInfo);
|
|
}
|
|
} |