MicroFrameWork/kernel/CgRouteCollector.php

61 lines
2.5 KiB
PHP
Raw Normal View History

2024-07-29 15:57:20 +03:00
<?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);
}
2024-10-07 16:13:46 +03:00
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);
}
2024-07-29 15:57:20 +03:00
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
2024-07-29 15:57:20 +03:00
{
$additionalInfo['type'] = "console";
$this->addRoute(Route::GET, $route, $handler, $filters, $additionalInfo);
2024-07-29 15:57:20 +03:00
}
}