Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

III-4866 refactor EditPlaceRestController to 2 handlers-1/2-updateAddress() #1101

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 1 addition & 2 deletions app/Place/PlaceControllerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ function (Application $app) {

$app[UpdateAddressRequestHandler::class] = $app->share(
fn (Application $app) => new UpdateAddressRequestHandler(
$app['event_command_bus'],
$app['place_jsonld_repository']
$app['event_command_bus']
)
);

Expand Down
16 changes: 1 addition & 15 deletions src/Http/Place/UpdateAddressRequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@
namespace CultuurNet\UDB3\Http\Place;

use Broadway\CommandHandling\CommandBus;
use CultuurNet\UDB3\EntityNotFoundException;
use CultuurNet\UDB3\Http\Deserializer\Address\AddressJSONDeserializer;
use CultuurNet\UDB3\Http\Request\RouteParameters;
use CultuurNet\UDB3\Http\Response\NoContentResponse;
use CultuurNet\UDB3\Language;
use CultuurNet\UDB3\Place\Commands\UpdateAddress;
use CultuurNet\UDB3\ReadModel\DocumentDoesNotExist;
use CultuurNet\UDB3\ReadModel\DocumentRepository;
use CultuurNet\UDB3\StringLiteral;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
Expand All @@ -22,12 +19,9 @@ final class UpdateAddressRequestHandler implements RequestHandlerInterface
{
private CommandBus $commandBus;

private DocumentRepository $placeDocumentRepository;

public function __construct(CommandBus $commandBus, DocumentRepository $placeDocumentRepository)
public function __construct(CommandBus $commandBus)
{
$this->commandBus = $commandBus;
$this->placeDocumentRepository = $placeDocumentRepository;
}

public function handle(ServerRequestInterface $request): ResponseInterface
Expand All @@ -40,14 +34,6 @@ public function handle(ServerRequestInterface $request): ResponseInterface
new StringLiteral($request->getBody()->getContents())
);

try {
$this->placeDocumentRepository->fetch($placeId);
} catch (DocumentDoesNotExist $e) {
throw new EntityNotFoundException(
sprintf('Place with id: %s not found.', $placeId)
);
}

$this->commandBus->dispatch(
new UpdateAddress($placeId, $address, Language::fromUdb3ModelLanguage($language))
);
Expand Down
3 changes: 1 addition & 2 deletions tests/Http/Place/UpdateAddressRequestHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ protected function setUp(): void
);

$this->updateAddressRequestHandler = new UpdateAddressRequestHandler(
$this->commandBus,
$placeDocumentRepository
JonasVHG marked this conversation as resolved.
Show resolved Hide resolved
$this->commandBus
);

$this->psr7RequestBuilder = new Psr7RequestBuilder();
Expand Down