Skip to content

Commit

Permalink
Add event after bulk category assignment (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrej-kuhnel authored Sep 3, 2020
1 parent 0648ac4 commit 70ef715
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 67 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ before_install:
install:
- composer require "sylius/sylius:${SYLIUS_VERSION}" --no-interaction --no-update
- composer update --no-interaction --prefer-dist
- (cd tests/Application && yarn install)
# - (cd tests/Application && yarn install)

before_script:
- (cd tests/Application && bin/console doctrine:database:create --env=test -vvv)
- (cd tests/Application && bin/console doctrine:schema:create --env=test -vvv)
# - (cd tests/Application && bin/console assets:install web --env=test -vvv)
- (cd tests/Application && bin/console cache:warmup --env=test -vvv)
- (cd tests/Application && yarn build)
- (cd tests/Application && bin/console assets:install public --env=test -vvv)
- (cd tests/Application && bin/console cache:clear --env=test -vvv)
# - (cd tests/Application && yarn build)

# Run webserver
- (cd tests/Application && bin/console server:run 127.0.0.1:8080 -d web --env=test --quiet > /dev/null 2>&1 &)
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# CHANGELOG

## v1.2.0 (2020-09-03)

#### Details

- Add event after bulk category assignment. (Eg. for update products in elasticsearch)

## v1.1.1 (2020-06-08)

#### Details

- CS translations

## v1.1.0 (2020-06-08)

#### Details

- Batch assign categories to products

## v1.0.0 (2020-04-28)

#### Details
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ Run `src/Migrations/basic-data/timezones-data.sql` for load the timezones table.
* `mango-sylius-extended-channels.duplicate.product.after-persist`
* `mango-sylius-extended-channels.duplicate.product-variant.before-persist`
* `mango-sylius-extended-channels.duplicate.product-variant.after-persist`

* You can use event after bulk category assignment
* `mango-sylius-extended-channels.products.after_bulk_categories`

* You can change the types of Hello bars
```yaml
Expand Down
15 changes: 14 additions & 1 deletion src/Controller/ManageProductCategoriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Core\Repository\ProductRepositoryInterface;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -49,14 +51,20 @@ class ManageProductCategoriesController
*/
private $formFactory;

/**
* @var EventDispatcherInterface
*/
private $eventDispatcher;

public function __construct(
TranslatorInterface $translator,
FlashBagInterface $flashBag,
RouterInterface $router,
ProductRepositoryInterface $productRepository,
EngineInterface $templatingEngine,
EntityManagerInterface $entityManager,
FormFactoryInterface $formFactory
FormFactoryInterface $formFactory,
EventDispatcherInterface $eventDispatcher
) {
$this->router = $router;
$this->flashBag = $flashBag;
Expand All @@ -65,6 +73,7 @@ public function __construct(
$this->templatingEngine = $templatingEngine;
$this->entityManager = $entityManager;
$this->formFactory = $formFactory;
$this->eventDispatcher = $eventDispatcher;
}

public function bulkManageProductCategories(Request $request): Response
Expand All @@ -85,6 +94,10 @@ public function bulkManageProductCategories(Request $request): Response
$message = $this->translator->trans('mango-sylius.admin.manage_product_categories.saved');
$this->flashBag->add('success', $message);

// Eg. for update products in elasticsearch
$event = new GenericEvent($productIds);
$this->eventDispatcher->dispatch('mango-sylius-extended-channels.products.after_bulk_categories', $event);

return new RedirectResponse($this->router->generate('sylius_admin_product_index'));
}

Expand Down
1 change: 1 addition & 0 deletions src/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ services:
$templatingEngine: '@templating'
$entityManager: '@doctrine.orm.default_entity_manager'
$formFactory: '@form.factory'
$eventDispatcher: '@event_dispatcher'

MangoSylius\ExtendedChannelsPlugin\Service\ProductDuplicator:
arguments:
Expand Down
111 changes: 56 additions & 55 deletions tests/Application/package.json
Original file line number Diff line number Diff line change
@@ -1,57 +1,58 @@
{
"dependencies": {
"babel-polyfill": "^6.26.0",
"jquery": "^3.2.0",
"lightbox2": "^2.9.0",
"semantic-ui-css": "^2.2.0",
"chart.js": "^2.9.3",
"slick-carousel": "^1.8.1"
},
"devDependencies": {
"babel-core": "^6.26.3",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-module-resolver": "^3.1.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-register": "^6.26.0",
"dedent": "^0.7.0",
"eslint": "^4.19.1",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-import-resolver-babel-module": "^4.0.0",
"eslint-plugin-import": "^2.12.0",
"fast-async": "^6.3.7",
"gulp": "^4.0.0",
"gulp-chug": "^0.5",
"gulp-concat": "^2.6.0",
"gulp-debug": "^2.1.2",
"gulp-if": "^2.0.0",
"gulp-livereload": "^3.8.1",
"gulp-order": "^1.1.1",
"gulp-sass": "^4.0.1",
"gulp-sourcemaps": "^1.6.0",
"gulp-uglifycss": "^1.0.5",
"merge-stream": "^1.0.0",
"rollup": "^0.60.7",
"rollup-plugin-babel": "^3.0.4",
"rollup-plugin-commonjs": "^9.1.3",
"rollup-plugin-inject": "^2.0.0",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-uglify": "^4.0.0",
"upath": "^1.1.0",
"yargs": "^6.4.0",
"@symfony/webpack-encore": "^0.28.0",
"sass-loader": "^7.0.1"
},
"scripts": {
"build": "gulp build",
"gulp": "gulp build",
"lint": "yarn lint:js",
"lint:js": "eslint gulpfile.babel.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Sylius/Sylius.git"
},
"author": "Paweł Jędrzejewski",
"license": "MIT"
"dependencies": {
"babel-polyfill": "^6.26.0",
"chart.js": "^2.9.3",
"jquery": "^3.4.0",
"jquery.dirtyforms": "^2.0.0",
"lightbox2": "^2.9.0",
"semantic-ui-css": "^2.2.0",
"slick-carousel": "^1.8.1"
},
"devDependencies": {
"@symfony/webpack-encore": "^0.28.0",
"babel-core": "^6.26.3",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-module-resolver": "^3.1.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-register": "^6.26.0",
"dedent": "^0.7.0",
"eslint": "^4.19.1",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-import-resolver-babel-module": "^4.0.0",
"eslint-plugin-import": "^2.11.0",
"fast-async": "^6.3.7",
"gulp": "^4.0.0",
"gulp-chug": "^0.5",
"gulp-concat": "^2.6.0",
"gulp-debug": "^2.1.2",
"gulp-if": "^2.0.0",
"gulp-livereload": "^4.0.1",
"gulp-order": "^1.1.1",
"gulp-sass": "^4.0.1",
"gulp-sourcemaps": "^1.6.0",
"gulp-uglifycss": "^1.0.5",
"merge-stream": "^1.0.0",
"rollup": "^0.60.2",
"rollup-plugin-babel": "^3.0.4",
"rollup-plugin-commonjs": "^9.1.3",
"rollup-plugin-inject": "^2.0.0",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-uglify": "^4.0.0",
"sass-loader": "^7.0.1",
"upath": "^1.1.0",
"yargs": "^6.4.0"
},
"scripts": {
"build": "gulp build",
"gulp": "gulp build",
"lint": "yarn lint:js",
"lint:js": "eslint gulpfile.babel.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Sylius/Sylius.git"
},
"author": "Paweł Jędrzejewski",
"license": "MIT"
}
14 changes: 7 additions & 7 deletions tests/Behat/Resources/suites.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
imports:
- suites/mark_taxon_as_external_link.yml
# - suites/managing_channel.yml
# - suites/send_order_email_to_bcc_email.yml
# - suites/cancel_unpaid_orders_for_certain_payment_method.yml
# - suites/update_product_prices_using_exchange_rates.yml
# - suites/download_current_exchange_rates.yml
# - suites/duplicate_product.yml
# - suites/duplicate_product_variant.yml
- suites/managing_channel.yml
- suites/send_order_email_to_bcc_email.yml
- suites/cancel_unpaid_orders_for_certain_payment_method.yml
- suites/update_product_prices_using_exchange_rates.yml
- suites/download_current_exchange_rates.yml
- suites/duplicate_product.yml
- suites/duplicate_product_variant.yml

0 comments on commit 70ef715

Please sign in to comment.