Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Tqdev/PhpCrudApi/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ public function __construct(Config $config)
$geoJson = new GeoJsonService($reflection, $records);
new GeoJsonController($router, $responder, $geoJson);
break;
default:
$controllerChunks = explode(':', $controller);
if (count($controllerChunks) === 2 && $controllerChunks[0] === 'custom') {
$className = $controllerChunks[1];
if (class_exists($className)) {
$records = new RecordService($db, $reflection);
new $className($router, $responder, $records);
}
}
break;
}
}
$this->router = $router;
Expand Down
23 changes: 23 additions & 0 deletions src/Tqdev/PhpCrudApi/Controller/CustomController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
namespace Tqdev\PhpCrudApi\Controller;

use Tqdev\PhpCrudApi\Middleware\Router\Router;
use Tqdev\PhpCrudApi\Record\RecordService;

abstract class CustomController
{
protected $service;
protected $responder;

public function __construct(Router $router, Responder $responder, RecordService $service)
{
$this->registerRoutes($router);

$this->service = $service;
$this->responder = $responder;
}

protected function registerRoutes(Router $router)
{
}
}