Skip to content

Commit 250716e

Browse files
committed
feat(dist): add channel context dist file
1 parent 3e29349 commit 250716e

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/*
4+
* This file is part of Monsieur Biz' Media Manager plugin for Sylius.
5+
*
6+
* (c) Monsieur Biz <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE.txt
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace App\Context\Channel\RequestBased;
15+
16+
use Sylius\Component\Channel\Context\RequestBased\RequestResolverInterface;
17+
use Sylius\Component\Channel\Model\ChannelInterface;
18+
use Sylius\Component\Channel\Repository\ChannelRepositoryInterface;
19+
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
20+
use Symfony\Component\HttpFoundation\Request;
21+
22+
#[AutoconfigureTag('sylius.context.channel.request_based.resolver')]
23+
final class HostnameAndPortBasedRequestResolver implements RequestResolverInterface
24+
{
25+
public function __construct(private ChannelRepositoryInterface $channelRepository)
26+
{
27+
}
28+
29+
public function findChannel(Request $request): ?ChannelInterface
30+
{
31+
return $this->channelRepository->findOneEnabledByHostname($request->getHost() . ':' . $request->getPort());
32+
}
33+
}

0 commit comments

Comments
 (0)