-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathRedirectToSpeakerTalksResponder.php
More file actions
48 lines (39 loc) · 1.19 KB
/
RedirectToSpeakerTalksResponder.php
File metadata and controls
48 lines (39 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace App\State\Responder;
use App\Entity\Speaker;
use Sylius\Resource\Context\Context;
use Sylius\Resource\Metadata\Operation;
use Sylius\Resource\State\ResponderInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\RouterInterface;
use Webmozart\Assert\Assert;
final class RedirectToSpeakerTalksResponder implements ResponderInterface
{
public function __construct(
private readonly RouterInterface $router,
) {
}
/**
* @param Speaker[] $data
*/
public function respond(mixed $data, Operation $operation, Context $context): RedirectResponse
{
Assert::allIsInstanceOf($data, Speaker::class);
$ids = array_map(fn (Speaker $speaker) => $speaker->getId(), $data);
$path = $this->router->generate('app_admin_talk_index', [
'criteria' => [
'speaker' => $ids,
],
]);
return new RedirectResponse($path);
}
}