Skip to content

[RFC]: Call repositories via the services in handlers #395

@alexmerlin

Description

@alexmerlin

RFC

Instead of using:

ExampleHandler.php:

public function handle(ServerRequestInterface $request): ResponseInterface
{
    $entity = $handler->exampleService->findOneBy($params);
    // ...
}

ExampleService.php:

public function findOneBy(array $params): Example
{
    return $this->exampleRepository->findOneBy($params);
}

we should use:

ExampleHandler.php:

public function handle(ServerRequestInterface $request): ResponseInterface
{
    $entity = $handler->exampleService->getExampleRepository()->findOneBy($params);
    // ...
}

This way we would simplify a lot the existing services and could drop tons of service methods that have a single purpose of receiving request params from the handler and returning the data provided by the repository.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions