Skip to content

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

Closed

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.

Activity

  1. self-assigned this
    on Mar 21, 2025
  2. changed the title [-][RFC]: Use repositories instead of services in handlers[/-] [+][RFC]: Call repositories via the services in handlers[/+] on Mar 21, 2025
  3. linked a pull request that will close this issueIssue #394: Service refactoring #396on Mar 25, 2025
  4. alexmerlin commented on Mar 25, 2025

    @alexmerlin
    MemberAuthor

    Implemented in #396

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    ⌂ Proxy