Skip to content
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
merged 3 commits into from
Oct 6, 2021

Conversation

GSadee
Copy link
Member

@GSadee 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 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
@GSadee GSadee requested a review from a team as a code owner October 6, 2021 06:02
@probot-autolabeler probot-autolabeler bot added the Maintenance CI configurations, READMEs, releases, etc. label 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"/>
Copy link
Member

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)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!isset($this->scopeValidators[$type])?

@Zales0123 Zales0123 merged commit 61dee95 into Sylius:master Oct 6, 2021
@Zales0123
Copy link
Member

Thank you, Grzegorz! 🥇

@GSadee GSadee deleted the refactor-scope-validator branch October 6, 2021 11:35
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants