mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-03 07:04:07 +01:00
refactor: [WIP] Use hexagonal architecture and implement interfaces for services and repositories.
Controllers are being splited into commands to better dependency management. Signed-off-by: Rubén D <nuxsmin@syspass.org>
This commit is contained in:
@@ -28,16 +28,16 @@ use Exception;
|
||||
use Klein\Klein;
|
||||
use League\Fractal\Manager;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use SP\Config\ConfigDataInterface;
|
||||
use SP\Core\Acl\Acl;
|
||||
use SP\Core\Application;
|
||||
use SP\Core\Context\ContextInterface;
|
||||
use SP\Core\Events\EventDispatcher;
|
||||
use SP\Core\Exceptions\SPException;
|
||||
use SP\Domain\Api\ApiServiceInterface;
|
||||
use SP\Domain\Api\Services\ApiResponse;
|
||||
use SP\Domain\Api\Services\JsonRpcResponse;
|
||||
use SP\Domain\Config\In\ConfigDataInterface;
|
||||
use SP\Http\Json;
|
||||
use SP\Services\Api\ApiResponse;
|
||||
use SP\Services\Api\ApiService;
|
||||
use SP\Services\Api\JsonRpcResponse;
|
||||
use SP\Services\ServiceException;
|
||||
|
||||
/**
|
||||
* Class ControllerBase
|
||||
@@ -48,34 +48,34 @@ abstract class ControllerBase
|
||||
{
|
||||
protected const SEARCH_COUNT_ITEMS = 25;
|
||||
|
||||
protected ContainerInterface $dic;
|
||||
protected string $controllerName;
|
||||
protected string $actionName;
|
||||
protected ContextInterface $context;
|
||||
protected EventDispatcher $eventDispatcher;
|
||||
protected ApiService $apiService;
|
||||
protected Klein $router;
|
||||
protected ContainerInterface $dic;
|
||||
protected string $controllerName;
|
||||
protected ContextInterface $context;
|
||||
protected EventDispatcher $eventDispatcher;
|
||||
protected ApiServiceInterface $apiService;
|
||||
protected Klein $router;
|
||||
protected ConfigDataInterface $configData;
|
||||
protected Manager $fractal;
|
||||
protected Acl $acl;
|
||||
private bool $isAuthenticated = false;
|
||||
protected Manager $fractal;
|
||||
protected Acl $acl;
|
||||
private bool $isAuthenticated = false;
|
||||
|
||||
final public function __construct(
|
||||
ContainerInterface $container,
|
||||
string $actionName
|
||||
)
|
||||
{
|
||||
$this->dic = $container;
|
||||
$this->context = $container->get(ContextInterface::class);
|
||||
$this->configData = $container->get(ConfigDataInterface::class);
|
||||
$this->eventDispatcher = $container->get(EventDispatcher::class);
|
||||
$this->router = $container->get(Klein::class);
|
||||
$this->apiService = $container->get(ApiService::class);
|
||||
$this->acl = $container->get(Acl::class);
|
||||
public function __construct(
|
||||
Application $application,
|
||||
Klein $router,
|
||||
ApiServiceInterface $apiService,
|
||||
Acl $acl
|
||||
) {
|
||||
$this->context = $application->getContext();
|
||||
$this->configData = $application->getConfig()->getConfigData();
|
||||
$this->eventDispatcher = $application->getEventDispatcher();
|
||||
$this->router = $router;
|
||||
$this->apiService = $apiService;
|
||||
$this->acl = $acl;
|
||||
$this->fractal = new Manager();
|
||||
|
||||
$this->controllerName = $this->getControllerName();
|
||||
$this->actionName = $actionName;
|
||||
// FIXME: provide action name
|
||||
// $this->actionName = $actionName;
|
||||
|
||||
if (method_exists($this, 'initialize')) {
|
||||
$this->initialize();
|
||||
@@ -89,12 +89,13 @@ abstract class ControllerBase
|
||||
return substr(
|
||||
$class,
|
||||
strrpos($class, '\\') + 1,
|
||||
-strlen('Controller')) ?: '';
|
||||
-strlen('Controller')
|
||||
) ?: '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws SPException
|
||||
* @throws ServiceException
|
||||
* @throws \SP\Domain\Common\Services\ServiceException
|
||||
*/
|
||||
final protected function setupApi(int $actionId): void
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user