-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1101 from cultuurnet/feature/III-4866-refactor-Ed…
…itPlaceRestController-into-2-handlers-updateAddress III-4866 refactor EditPlaceRestController to 2 handlers-1/2-updateAddress()
- Loading branch information
Showing
11 changed files
with
355 additions
and
316 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace CultuurNet\UDB3\Http\Place; | ||
|
||
use Broadway\CommandHandling\CommandBus; | ||
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\StringLiteral; | ||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Psr\Http\Server\RequestHandlerInterface; | ||
|
||
final class UpdateAddressRequestHandler implements RequestHandlerInterface | ||
{ | ||
private CommandBus $commandBus; | ||
|
||
public function __construct(CommandBus $commandBus) | ||
{ | ||
$this->commandBus = $commandBus; | ||
} | ||
|
||
public function handle(ServerRequestInterface $request): ResponseInterface | ||
{ | ||
$routeParameters = new RouteParameters($request); | ||
$placeId = $routeParameters->getPlaceId(); | ||
$language = $routeParameters->getLanguage(); | ||
|
||
$address = (new AddressJSONDeserializer())->deserialize( | ||
new StringLiteral($request->getBody()->getContents()) | ||
); | ||
|
||
$this->commandBus->dispatch( | ||
new UpdateAddress($placeId, $address, Language::fromUdb3ModelLanguage($language)) | ||
); | ||
|
||
return new NoContentResponse(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.