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

Upgrade plugin to Sylius 2.0 [WIP] #257

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
"require": {
"php": "^8.1",
"ext-json": "*",
"friendsofsymfony/elastica-bundle": "^6.0",
"sylius/sylius": "~1.13.0",
"symfony/property-access": "^5.4 || ^6.0",
"symfony/webpack-encore-bundle": "^1.15",
"symfony/proxy-manager-bridge": "^5.4 || ^6.0"
"friendsofsymfony/elastica-bundle": "^6.4",
"symfony/property-access": "^6.4",
"symfony/proxy-manager-bridge": "^6.4",
"symfony/stimulus-bundle": "^2.19",
"symfony/ux-autocomplete": "^2.19",
"symfony/ux-live-component": "^2.19",
"sylius/sylius": "~2.0.0",
"symfony/webpack-encore-bundle": "^2.0"
},
"require-dev": {
"behat/behat": "^3.6.1",
Expand Down Expand Up @@ -40,16 +43,17 @@
"robertfausk/behat-panther-extension": "^1.1",
"sylius-labs/coding-standard": "^4.2",
"sylius-labs/suite-tags-extension": "^0.2",
"symfony/browser-kit": "^5.4 || ^6.0",
"symfony/debug-bundle": "^5.4 || ^6.0",
"symfony/dotenv": "^5.4 || ^6.0",
"symfony/intl": "^5.4 || ^6.0",
"symfony/web-profiler-bundle": "^5.4 || ^6.0"
"symfony/dotenv": "^6.4",
"symfony/intl": "^6.4",
"symfony/browser-kit": "^6.4 || ^7.1",
"symfony/debug-bundle": "^6.4 || ^7.1",
"symfony/http-client": "^6.4 || ^7.1",
"symfony/intl": "^6.4 || ^7.1",
"symfony/web-profiler-bundle": "^6.4 || ^7.1"
},
"conflict": {
"api-platform/core": "v2.7.17",
"symfony/framework-bundle": "6.2.8",
"behat/mink-selenium2-driver": ">=1.7.0"
"symfony/framework-bundle": "6.2.8"
},
"config": {
"sort-packages": true,
Expand All @@ -62,10 +66,9 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.13-dev"
},
"symfony": {
"require": "^5.4 || ^6.0"
"require": "^6.0 || ^7.0"
}
},
"autoload": {
Expand Down
251 changes: 251 additions & 0 deletions src/Resources/config/Product.xml

Large diffs are not rendered by default.

251 changes: 0 additions & 251 deletions src/Resources/config/api_resources/Product.xml

This file was deleted.

84 changes: 42 additions & 42 deletions src/Resources/config/services/event_listener.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,47 @@

<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="bitbag_sylius_elasticsearch_plugin.event_listener.resource_index" class="BitBag\SyliusElasticsearchPlugin\EventListener\ResourceIndexListener">
<argument type="service" id="bitbag.sylius_elasticsearch_plugin.refresher.resource" />
<argument type="collection">
<argument type="collection">
<argument key="model">%sylius.model.product_attribute.class%</argument>
<argument key="serviceId" type="service" id="fos_elastica.object_persister.bitbag_attribute_taxons" />
</argument>
<argument type="collection">
<argument key="model">%sylius.model.product_option.class%</argument>
<argument key="serviceId" type="service" id="fos_elastica.object_persister.bitbag_option_taxons" />
</argument>
<argument type="collection">
<argument key="getParentMethod">getProduct</argument>
<argument key="model">%sylius.model.product.class%</argument>
<argument key="serviceId" type="service" id="fos_elastica.object_persister.bitbag_shop_product" />
</argument>
</argument>
<argument type="service" id="sylius.repository.product_attribute"/>
<argument type="service" id="sylius.repository.product_option"/>
<tag name="kernel.event_listener" event="sylius.product_attribute.post_create" method="updateIndex" />
<tag name="kernel.event_listener" event="sylius.product_attribute.post_update" method="updateIndex" />
<tag name="kernel.event_listener" event="sylius.product_attribute.post_delete" method="updateIndex" />
<tag name="kernel.event_listener" event="sylius.option.post_create" method="updateIndex" />
<tag name="kernel.event_listener" event="sylius.option.post_update" method="updateIndex" />
<tag name="kernel.event_listener" event="sylius.option.post_delete" method="updateIndex" />
<tag name="kernel.event_listener" event="sylius.product.post_create" method="updateIndex" />
<tag name="kernel.event_listener" event="sylius.product.post_update" method="updateIndex" />
<tag name="kernel.event_listener" event="sylius.product.post_delete" method="updateIndex" />
<tag name="kernel.event_listener" event="sylius.product_variant.post_create" method="updateIndex" />
<tag name="kernel.event_listener" event="sylius.product_variant.post_update" method="updateIndex" />
<tag name="kernel.event_listener" event="sylius.product_variant.post_delete" method="updateIndex" />
</service>
<service id="bitbag_sylius_elasticsearch_plugin.event_listener.product_taxon_index" class="BitBag\SyliusElasticsearchPlugin\EventListener\ProductTaxonIndexListener">
<argument type="service" id="bitbag.sylius_elasticsearch_plugin.refresher.resource" />
<argument type="service" id="fos_elastica.object_persister.bitbag_shop_product" />
<tag name="doctrine.orm.entity_listener" event="postUpdate" method="updateIndex" entity="%sylius.model.product_taxon.class%" />
</service>
<service id="bitbag_sylius_elasticsearch_plugin.event_listener.order_products" class="BitBag\SyliusElasticsearchPlugin\EventListener\OrderProductsListener" public="true">
<argument type="service" id="bitbag.sylius_elasticsearch_plugin.refresher.resource" />
<argument type="service" id="fos_elastica.object_persister.bitbag_shop_product" />
<tag name="kernel.event_listener" event="sylius.order.post_complete" method="updateOrderProducts" />
</service>
<!-- <service id="bitbag_sylius_elasticsearch_plugin.event_listener.resource_index" class="BitBag\SyliusElasticsearchPlugin\EventListener\ResourceIndexListener">-->
<!-- <argument type="service" id="bitbag.sylius_elasticsearch_plugin.refresher.resource" />-->
<!-- <argument type="collection">-->
<!-- <argument type="collection">-->
<!-- <argument key="model">%sylius.model.product_attribute.class%</argument>-->
<!-- <argument key="serviceId" type="service" id="fos_elastica.object_persister.bitbag_attribute_taxons" />-->
<!-- </argument>-->
<!-- <argument type="collection">-->
<!-- <argument key="model">%sylius.model.product_option.class%</argument>-->
<!-- <argument key="serviceId" type="service" id="fos_elastica.object_persister.bitbag_option_taxons" />-->
<!-- </argument>-->
<!-- <argument type="collection">-->
<!-- <argument key="getParentMethod">getProduct</argument>-->
<!-- <argument key="model">%sylius.model.product.class%</argument>-->
<!-- <argument key="serviceId" type="service" id="fos_elastica.object_persister.bitbag_shop_product" />-->
<!-- </argument>-->
<!-- </argument>-->
<!-- <argument type="service" id="sylius.repository.product_attribute"/>-->
<!-- <argument type="service" id="sylius.repository.product_option"/>-->
<!-- <tag name="kernel.event_listener" event="sylius.product_attribute.post_create" method="updateIndex" />-->
<!-- <tag name="kernel.event_listener" event="sylius.product_attribute.post_update" method="updateIndex" />-->
<!-- <tag name="kernel.event_listener" event="sylius.product_attribute.post_delete" method="updateIndex" />-->
<!-- <tag name="kernel.event_listener" event="sylius.option.post_create" method="updateIndex" />-->
<!-- <tag name="kernel.event_listener" event="sylius.option.post_update" method="updateIndex" />-->
<!-- <tag name="kernel.event_listener" event="sylius.option.post_delete" method="updateIndex" />-->
<!-- <tag name="kernel.event_listener" event="sylius.product.post_create" method="updateIndex" />-->
<!-- <tag name="kernel.event_listener" event="sylius.product.post_update" method="updateIndex" />-->
<!-- <tag name="kernel.event_listener" event="sylius.product.post_delete" method="updateIndex" />-->
<!-- <tag name="kernel.event_listener" event="sylius.product_variant.post_create" method="updateIndex" />-->
<!-- <tag name="kernel.event_listener" event="sylius.product_variant.post_update" method="updateIndex" />-->
<!-- <tag name="kernel.event_listener" event="sylius.product_variant.post_delete" method="updateIndex" />-->
<!-- </service>-->
<!-- <service id="bitbag_sylius_elasticsearch_plugin.event_listener.product_taxon_index" class="BitBag\SyliusElasticsearchPlugin\EventListener\ProductTaxonIndexListener">-->
<!-- <argument type="service" id="bitbag.sylius_elasticsearch_plugin.refresher.resource" />-->
<!-- <argument type="service" id="fos_elastica.object_persister.bitbag_shop_product" />-->
<!-- <tag name="doctrine.orm.entity_listener" event="postUpdate" method="updateIndex" entity="%sylius.model.product_taxon.class%" />-->
<!-- </service>-->
<!-- <service id="bitbag_sylius_elasticsearch_plugin.event_listener.order_products" class="BitBag\SyliusElasticsearchPlugin\EventListener\OrderProductsListener" public="true">-->
<!-- <argument type="service" id="bitbag.sylius_elasticsearch_plugin.refresher.resource" />-->
<!-- <argument type="service" id="fos_elastica.object_persister.bitbag_shop_product" />-->
<!-- <tag name="kernel.event_listener" event="sylius.order.post_complete" method="updateOrderProducts" />-->
<!-- </service>-->
</services>
</container>
3 changes: 2 additions & 1 deletion src/Resources/views/Shop/Menu/_searchForm.html.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<div class="searchdiv" data-bb-elastic-url="{{ url('bitbag_sylius_elasticsearch_plugin_shop_auto_complete_product_name') }}">
{#<div class="searchdiv" data-bb-elastic-url="{{ url('bitbag_sylius_elasticsearch_plugin_shop_auto_complete_product_name') }}">#}
<div class="searchdiv" data-bb-elastic-url="/">
<div class="ui fluid category search">
<div class="ui icon input" style="width: 100%;">

Expand Down
5 changes: 3 additions & 2 deletions src/Twig/ContextProvider/SearchFormProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use BitBag\SyliusElasticsearchPlugin\Form\Type\SearchType;
use Sylius\Bundle\UiBundle\ContextProvider\ContextProviderInterface;
use Sylius\Bundle\UiBundle\Registry\Block;
use Sylius\Bundle\UiBundle\Registry\TemplateBlock;
use Symfony\Component\Form\FormFactoryInterface;

Expand All @@ -28,15 +29,15 @@ public function __construct(
) {
}

public function provide(array $templateContext, TemplateBlock $templateBlock): array
public function provide(array $templateContext, Block $templateBlock): array
{
$form = $this->formFactory->create(SearchType::class);
$templateContext['form'] = $form->createView();

return $templateContext;
}

public function supports(TemplateBlock $templateBlock): bool
public function supports(Block $templateBlock): bool
{
return self::EVENT_NAME === $templateBlock->getEventName()
&& self::BLOCK_NAME === $templateBlock->getName();
Expand Down
2 changes: 1 addition & 1 deletion tests/Application/assets/admin/entry.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import 'sylius/bundle/AdminBundle/Resources/private/entry';
import 'sylius/bundle/AdminBundle/Resources/assets/entrypoint';
5 changes: 5 additions & 0 deletions tests/Application/assets/controllers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"controllers": {
},
"entrypoints": []
}
2 changes: 1 addition & 1 deletion tests/Application/assets/shop/entry.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import 'sylius/bundle/ShopBundle/Resources/private/entry';
import 'sylius/bundle/ShopBundle/Resources/assets/entrypoint';
3 changes: 1 addition & 2 deletions tests/Application/config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,14 @@
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true],
FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true, 'test_cached' => true],
Sylius\Behat\Application\SyliusTestPlugin\SyliusTestPlugin::class => ['test' => true, 'test_cached' => true],
ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true],
ApiPlatform\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true],
Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true],
Sylius\Bundle\ApiBundle\SyliusApiBundle::class => ['all' => true],
SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true],
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle::class => ['test' => true],
Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle::class => ['test' => true],
League\FlysystemBundle\FlysystemBundle::class => ['all' => true],
Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true],
BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true],
];

Expand Down
15 changes: 14 additions & 1 deletion tests/Application/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
{
"dependencies": {
"@babel/polyfill": "^7.0.0",
"@popperjs/core": "^2.11.8",
"@tabler/core": "^1.0.0-beta21",
"apexcharts": "^3.53.0",
"bootstrap": "^5.3.3",
"chart.js": "^3.7.1",
"flag-icons": "^7.2.3",
"infinite-tree": "^1.18.0",
"jquery": "^3.5.0",
"jquery.dirtyforms": "^2.0.0",
"lightbox2": "^2.9.0",
"semantic-ui-css": "^2.2.0",
"slick-carousel": "^1.8.1"
},
"devDependencies": {
"@hotwired/stimulus": "^3.2.2",
"@symfony/stimulus-bridge": "^3.2.2",
"@symfony/ux-autocomplete": "file:../../vendor/symfony/ux-autocomplete/assets",
"@symfony/ux-live-component": "file:../../vendor/symfony/ux-live-component/assets",
"@symfony/webpack-encore": "^1.6.1",
"babel-core": "^6.26.3",
"babel-plugin-external-helpers": "^6.22.0",
Expand All @@ -23,7 +33,10 @@
"eslint-plugin-import": "^2.11.0",
"merge-stream": "^1.0.0",
"sass": "^1.39.2",
"sass-loader": "^12.1.0"
"sass-loader": "^12.1.0",
"slugify": "^1.6.6",
"stimulus-use": "^0.52.2",
"tom-select": "^2.3.1"
},
"scripts": {
"dev": "yarn encore dev",
Expand Down
7 changes: 5 additions & 2 deletions tests/Application/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const path = require('path');
const Encore = require('@symfony/webpack-encore');

const [bitbagElasticsearchShop, bitbagElasticsearchAdmin] = require('../../webpack.config.js')
const [bitbagElasticsearchShop, bitbagElasticsearchAdmin] = require('../../webpack.config.js');

const syliusBundles = path.resolve(__dirname, '../../vendor/sylius/sylius/src/Sylius/Bundle/');

const uiBundleScripts = path.resolve(syliusBundles, 'UiBundle/Resources/private/js/');
Expand All @@ -12,6 +13,7 @@ Encore
.setOutputPath('public/build/shop/')
.setPublicPath('/build/shop')
.addEntry('shop-entry', './assets/shop/entry.js')
.enableStimulusBridge('./assets/controllers.json')
.disableSingleRuntimeChunk()
.cleanupOutputBeforeBuild()
.enableSourceMaps(!Encore.isProduction())
Expand All @@ -32,6 +34,7 @@ Encore
.setOutputPath('public/build/admin/')
.setPublicPath('/build/admin')
.addEntry('admin-entry', './assets/admin/entry.js')
.enableStimulusBridge('./assets/controllers.json')
.disableSingleRuntimeChunk()
.cleanupOutputBeforeBuild()
.enableSourceMaps(!Encore.isProduction())
Expand All @@ -46,4 +49,4 @@ adminConfig.resolve.alias['sylius/bundle'] = syliusBundles;
adminConfig.externals = Object.assign({}, adminConfig.externals, { window: 'window', document: 'document' });
adminConfig.name = 'admin';

module.exports = [shopConfig, adminConfig, bitbagElasticsearchShop, bitbagElasticsearchAdmin];
module.exports = [shopConfig, adminConfig, bitbagElasticsearchShop, bitbagElasticsearchAdmin];
Loading