-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[CatalogPromotion] Refactor scope validators to be more extendable #13174
Merged
Conversation
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
Member
GSadee
commented
Oct 6, 2021
Q | A |
---|---|
Branch? | master |
Bug fix? | no |
New feature? | no |
BC breaks? | no |
Deprecations? | |
Related tickets | based on #13173 |
License | MIT |
GSadee
added
Enhancement
Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.).
DX
Issues and PRs aimed at improving Developer eXperience.
labels
Oct 6, 2021
probot-autolabeler
bot
added
the
Maintenance
CI configurations, READMEs, releases, etc.
label
Oct 6, 2021
arti0090
approved these changes
Oct 6, 2021
src/Sylius/Bundle/CoreBundle/Resources/config/services/validators.xml
Outdated
Show resolved
Hide resolved
GSadee
force-pushed
the
refactor-scope-validator
branch
from
October 6, 2021 09:58
168b61a
to
e3c6400
Compare
GSadee
force-pushed
the
refactor-scope-validator
branch
from
October 6, 2021 10:03
e3c6400
to
9efc29a
Compare
Zales0123
reviewed
Oct 6, 2021
src/Sylius/Bundle/CoreBundle/Resources/config/services/validators.xml
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/CoreBundle/Resources/config/services/validators.xml
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/CoreBundle/Validator/Constraints/CatalogPromotionScopeValidator.php
Outdated
Show resolved
Hide resolved
Zales0123
approved these changes
Oct 6, 2021
|
||
<service id="Sylius\Bundle\CoreBundle\Validator\CatalogPromotionScope\ForTaxonsScopeValidator"> | ||
<argument type="service" id="sylius.repository.taxon" /> | ||
<tag name="sylius.catalog_promotion.scope_validator" key="for_taxons"/> |
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.
Is it possible to use constants for these keys as well? 🤔
$this->context->buildViolation($constraint->variantsNotEmpty)->atPath('configuration.variants')->addViolation(); | ||
|
||
$type = $value->getType(); | ||
if (!key_exists($type, $this->scopeValidators)) { |
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.
!isset($this->scopeValidators[$type])
?
Thank you, Grzegorz! 🥇 |
GSadee
added a commit
that referenced
this pull request
Oct 8, 2021
…mic form configurations (Zales0123) This PR was merged into the 1.11-dev branch. Discussion ---------- | Q | A | --------------- | ----- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Related tickets | | License | MIT As we already have the second Catalog Promotions scope type, it's time for UI... which is always a pain in the back, when we need to struggle with dynamic form configurations in collections 💃 I decided, that our _traditional_ approach to the topic (used, for example) for cart promotions, has a too big technical overhead (with all registries, abstract configuration forms, prototypes), that I would like to try something new 🚀 Such an approach definitely needs some polishing (especially [in javascript](https://github.com/Sylius/Sylius/pull/13175/files#diff-8b6e14c05e37accab454bc9a0fe29b7da59136d1bfe75e41344f1fa8cd9d115eR13), cc @kulczy 😄), but should be fairly easy to use and extend. **Note:** for the first time, I've added form extension [in AdminBundle](https://github.com/Sylius/Sylius/pull/13175/files#diff-b310e0182332af844d2284fcd530749f7923af4354b997af40d2d137bfd0f9a2R13), as the choices attributes are needed only for our default templates and are not application logic. I believe we should follow the path to fully decouple _CoreBundle_ from the UI, especially if we want to be fully headless one day 🤯 After this PR and [the other one with validation refactoring](#13174), adding new scope would be mostly adding service, form type and validator with proper tags, as well as adding a template in the `@SyliusAdmin/CatalogPromotion/Scope` directory (could be parametrized, I suppose 🤔). It should definitely be included in the documentation 🏇 which will be provided in some of the next PRs 🖖 Commits ------- 30248df [Behat] Scenario for creating taxons-based catalog promotion a3544e4 Enable "For taxons" scope in UI with dynamic form b61c68a Refactor forms parameters and javascripts aafa357 Fix scenarios and coding standards 6b8554b Taxon-based scope validation 2502fe9 Javascript fixes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
DX
Issues and PRs aimed at improving Developer eXperience.
Enhancement
Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.).
Maintenance
CI configurations, READMEs, releases, etc.
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.