-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #15300 Provide autoconfiguration with attributes for ChannelB…
…undle (jakubtobiasz) This PR was merged into the 1.13 branch. Discussion ---------- | Q | A | |-----------------|--------------------------------------------------------------| | Branch? | 1.13 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Related tickets | continuation of #14154 | License | MIT Thanks @ffouillet for starting this initiative 🥳! Commits ------- 3c2f26a Provide autoconfiguration with attributes for ChannelBundle 0342759 Rename AsChannelContextRequestResolver.php to AsRequestBasedChannelResolver.php
- Loading branch information
Showing
7 changed files
with
182 additions
and
1 deletion.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
src/Sylius/Bundle/ChannelBundle/Attribute/AsChannelContext.php
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,29 @@ | ||
<?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 Sylius\Bundle\ChannelBundle\Attribute; | ||
|
||
#[\Attribute(\Attribute::TARGET_CLASS)] | ||
final class AsChannelContext | ||
{ | ||
public const SERVICE_TAG = 'sylius.context.channel'; | ||
|
||
public function __construct(private int $priority = 0) | ||
{ | ||
} | ||
|
||
public function getPriority(): int | ||
{ | ||
return $this->priority; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/Sylius/Bundle/ChannelBundle/Attribute/AsRequestBasedChannelResolver.php
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,29 @@ | ||
<?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 Sylius\Bundle\ChannelBundle\Attribute; | ||
|
||
#[\Attribute(\Attribute::TARGET_CLASS)] | ||
final class AsRequestBasedChannelResolver | ||
{ | ||
public const SERVICE_TAG = 'sylius.context.channel.request_based.resolver'; | ||
|
||
public function __construct(private int $priority = 0) | ||
{ | ||
} | ||
|
||
public function getPriority(): int | ||
{ | ||
return $this->priority; | ||
} | ||
} |
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
28 changes: 28 additions & 0 deletions
28
src/Sylius/Bundle/ChannelBundle/Tests/Stub/ChannelContextStub.php
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,28 @@ | ||
<?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 Sylius\Bundle\ChannelBundle\Tests\Stub; | ||
|
||
use Sylius\Bundle\ChannelBundle\Attribute\AsChannelContext; | ||
use Sylius\Component\Channel\Context\ChannelContextInterface; | ||
use Sylius\Component\Channel\Model\Channel; | ||
use Sylius\Component\Channel\Model\ChannelInterface; | ||
|
||
#[AsChannelContext(priority: 15)] | ||
final class ChannelContextStub implements ChannelContextInterface | ||
{ | ||
public function getChannel(): ChannelInterface | ||
{ | ||
return new Channel(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/Sylius/Bundle/ChannelBundle/Tests/Stub/RequestBestChannelResolverStub.php
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,28 @@ | ||
<?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 Sylius\Bundle\ChannelBundle\Tests\Stub; | ||
|
||
use Sylius\Bundle\ChannelBundle\Attribute\AsRequestBasedChannelResolver; | ||
use Sylius\Component\Channel\Context\RequestBased\RequestResolverInterface; | ||
use Sylius\Component\Channel\Model\ChannelInterface; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
#[AsRequestBasedChannelResolver(priority: 20)] | ||
final class RequestBestChannelResolverStub implements RequestResolverInterface | ||
{ | ||
public function findChannel(Request $request): ?ChannelInterface | ||
{ | ||
return null; | ||
} | ||
} |
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