-
-
Notifications
You must be signed in to change notification settings - Fork 9
Add visible flag to the ChannelPricingLogEntry #10
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
Draft
coldic3
wants to merge
4
commits into
Sylius:main
Choose a base branch
from
coldic3:feature/catalog-price-history-is-visible-flag
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,24 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
|
|
||
| <!-- | ||
|
|
||
| This file is part of the Sylius package. | ||
|
|
||
| (c) Paweł Jędrzejewski | ||
|
|
||
| For the full copyright and license information, please view the LICENSE | ||
| file that was distributed with this source code. | ||
|
|
||
| --> | ||
|
|
||
| <container xmlns="http://symfony.com/schema/dic/services" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" | ||
| > | ||
| <services> | ||
| <service | ||
| id="Sylius\PriceHistoryPlugin\Checker\ProductVariantVisibilityCheckerInterface" | ||
| class="Sylius\PriceHistoryPlugin\Checker\ProductVariantVisibilityChecker" | ||
| /> | ||
| </services> | ||
| </container> |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,84 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * This file is part of the Sylius package. | ||
| * | ||
| * (c) Paweł Jędrzejewski | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace spec\Sylius\PriceHistoryPlugin\Checker; | ||
|
|
||
| use PhpSpec\ObjectBehavior; | ||
| use Sylius\Component\Core\Model\ChannelInterface; | ||
| use Sylius\Component\Core\Model\ProductInterface; | ||
| use Sylius\Component\Core\Model\ProductVariantInterface; | ||
| use Sylius\PriceHistoryPlugin\Checker\ProductVariantVisibilityCheckerInterface; | ||
|
|
||
| class ProductVariantVisibilityCheckerSpec extends ObjectBehavior | ||
| { | ||
| function it_implements_product_visibility_checker_interface(): void | ||
| { | ||
| $this->shouldHaveType(ProductVariantVisibilityCheckerInterface::class); | ||
| } | ||
|
|
||
| function it_returns_true_if_product_variant_is_visible( | ||
| ProductVariantInterface $productVariant, | ||
| ChannelInterface $channel, | ||
| ProductInterface $product, | ||
| ): void { | ||
| $productVariant->getProduct()->willReturn($product); | ||
|
|
||
| $productVariant->isEnabled()->willReturn(true); | ||
| $product->isEnabled()->willReturn(true); | ||
| $product->hasChannel($channel)->willReturn(true); | ||
|
|
||
| $this->isVisibleInChannel($productVariant, $channel)->shouldReturn(true); | ||
| } | ||
|
|
||
| function it_returns_false_if_product_is_disabled( | ||
| ProductVariantInterface $productVariant, | ||
| ChannelInterface $channel, | ||
| ProductInterface $product, | ||
| ): void { | ||
| $productVariant->getProduct()->willReturn($product); | ||
|
|
||
| $productVariant->isEnabled()->willReturn(true); | ||
| $product->isEnabled()->willReturn(false); | ||
| $product->hasChannel($channel)->willReturn(true); | ||
|
|
||
| $this->isVisibleInChannel($productVariant, $channel)->shouldReturn(false); | ||
| } | ||
|
|
||
| function it_returns_false_if_product_is_disabled_for_a_given_channel( | ||
| ProductVariantInterface $productVariant, | ||
| ChannelInterface $channel, | ||
| ProductInterface $product, | ||
| ): void { | ||
| $productVariant->getProduct()->willReturn($product); | ||
|
|
||
| $productVariant->isEnabled()->willReturn(true); | ||
| $product->isEnabled()->willReturn(true); | ||
| $product->hasChannel($channel)->willReturn(false); | ||
|
|
||
| $this->isVisibleInChannel($productVariant, $channel)->shouldReturn(false); | ||
| } | ||
|
|
||
| function it_returns_false_if_product_variant_is_disabled( | ||
| ProductVariantInterface $productVariant, | ||
| ChannelInterface $channel, | ||
| ProductInterface $product, | ||
| ): void { | ||
| $productVariant->getProduct()->willReturn($product); | ||
|
|
||
| $productVariant->isEnabled()->willReturn(false); | ||
| $product->isEnabled()->willReturn(true); | ||
| $product->hasChannel($channel)->willReturn(true); | ||
|
|
||
| $this->isVisibleInChannel($productVariant, $channel)->shouldReturn(false); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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) Paweł Jędrzejewski | ||
| * | ||
| * 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\PriceHistoryPlugin\Checker; | ||
|
|
||
| use Sylius\Component\Core\Model\ChannelInterface; | ||
| use Sylius\Component\Core\Model\ProductVariantInterface; | ||
| use Webmozart\Assert\Assert; | ||
|
|
||
| class ProductVariantVisibilityChecker implements ProductVariantVisibilityCheckerInterface | ||
| { | ||
| public function isVisibleInChannel(ProductVariantInterface $productVariant, ChannelInterface $channel): bool | ||
| { | ||
| $product = $productVariant->getProduct(); | ||
| Assert::notNull($product); | ||
|
|
||
| return $productVariant->isEnabled() && $product->isEnabled() && $product->hasChannel($channel); | ||
| } | ||
| } |
This file contains hidden or 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,22 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * This file is part of the Sylius package. | ||
| * | ||
| * (c) Paweł Jędrzejewski | ||
| * | ||
| * 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\PriceHistoryPlugin\Checker; | ||
|
|
||
| use Sylius\Component\Core\Model\ChannelInterface; | ||
| use Sylius\Component\Core\Model\ProductVariantInterface; | ||
|
|
||
| interface ProductVariantVisibilityCheckerInterface | ||
| { | ||
| public function isVisibleInChannel(ProductVariantInterface $productVariant, ChannelInterface $channel): bool; | ||
| } |
This file contains hidden or 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 hidden or 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,31 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Sylius\PriceHistoryPlugin\Migrations; | ||
|
|
||
| use Doctrine\DBAL\Schema\Schema; | ||
| use Doctrine\Migrations\AbstractMigration; | ||
|
|
||
| /** | ||
| * Auto-generated Migration: Please modify to your needs! | ||
| */ | ||
| final class Version20230202130642 extends AbstractMigration | ||
| { | ||
| public function getDescription(): string | ||
| { | ||
| return 'Add `visible` field to the ChannelPricingLogEntry'; | ||
| } | ||
|
|
||
| public function up(Schema $schema): void | ||
| { | ||
| // this up() migration is auto-generated, please modify it to your needs | ||
| $this->addSql('ALTER TABLE sylius_price_history_channel_pricing_log_entry ADD visible TINYINT(1) NOT NULL'); | ||
| } | ||
|
|
||
| public function down(Schema $schema): void | ||
| { | ||
| // this down() migration is auto-generated, please modify it to your needs | ||
| $this->addSql('ALTER TABLE sylius_price_history_channel_pricing_log_entry DROP visible'); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OFC should be
admin:channel_pricing_log_entry:read