7.4 KiB
UPGRADE FROM v1.11.X TO v1.12.0
Main update
-
Service
sylius.twig.extension.taxeshas been deprecated. Use methodsgetTaxExcludedTotalandgetTaxIncludedTotalfromSylius\Component\Core\Model\Orderinstead. -
Both
getCreatedByGuestandsetCreatedByGuestmethods were deprecated on\Sylius\Component\Core\Model\Order. Please useisCreatedByGuestinstead of the first one. The latter is a part of thesetCustomerWithAuthorizationlogic and should be used only this way. -
Due to refactoring constructor has been changed in service
src/Sylius/Bundle/ShopBundle/EventListener/OrderIntegrityChecker.php:public function __construct( private RouterInterface $router, - private OrderProcessorInterface $orderProcessor, private ObjectManager $manager + private OrderPromotionsIntegrityCheckerInterface $orderPromotionsIntegrityChecker ) -
To allow administrator reset their password, add in
config/packages/security.yamlfile the following entry- { path: "%sylius.security.admin_regex%/forgotten-password", role: IS_AUTHENTICATED_ANONYMOUSLY }above
- { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS } -
It is worth noticing that, that the following services are now included in every env starting with
testkeyword. If you wish to not have them, either you need to rename your env to not start with test or remove these services with complier pass. -
The following listeners have been removed as they are not used anymore:
Sylius\Bundle\CoreBundle\CatalogPromotion\Listener\CatalogPromotionFailedListenerSylius\Bundle\CoreBundle\CatalogPromotion\Listener\CatalogPromotionUpdateFailedMessageListener
-
The
Sylius\Component\Promotion\Event\CatalogPromotionFailedhas been removed as it is not used anymore. -
Due to updating to Symfony 6 security file was changed to use the updated security system so you need to adjust your
config/packages/security.yamlfile:security: - always_authenticate_before_granting: true + enable_authenticator_manager: trueand you need to adjust all of your firewalls like that:
admin: # ... form_login: # ... - csrf_token_generator: security.csrf.token_manager + enable_csrf: true # ... new_api_admin_user: # ... - anonymous: true + entry_point: jwt # ... - guard: - authenticators: - # ... + jwt: true shop: logout: path: sylius_shop_logout - target: sylius_shop_login + target: sylius_shop_homepage invalidate_session: false - success_handler: sylius.handler.shop_user_logoutand also you need to adjust all of your access_control like that:
- - { path: "%sylius.security.admin_regex%/forgotten-password", role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: "%sylius.security.admin_regex%/forgotten-password", role: PUBLIC_ACCESS } -
Passing a
Gaufrette\FilesystemtoSylius\Component\Core\Uploader\ImageUploaderconstructor is deprecated since Sylius 1.12 and will be prohibited in 2.0. UseSylius\Component\Core\Filesystem\Adapter\FlysystemFilesystemAdapterinstead. -
Gaufrette is no longer used by Sylius in favour of Flysystem. If you want to use Gaufrette in your project, you need to set:
sylius_core: filesystem: adapter: gaufrettein your
config/packages/_sylius.yamlfile. -
Not passing
Sylius\Component\Taxation\Checker\TaxRateDateEligibilityCheckerInterfacetoSylius\Component\Taxation\Resolver\TaxRateResolveris deprecated since Sylius 1.12 and will be prohibited in 2.0
Frontend toolset changes
Dependencies update
In 1.12 we have updated our frontend dependencies to the latest versions. This means that you might need to update your dependencies as well.
The full list of all dependencies can be found in the package.json file.
Because every project is different, we cannot provide a list of all changes that might be needed. However, we have prepared a short list of fixes for the most common issues.
We updated gulp-sass plugin as well as the sass implementation we use to be compatible with most installation (node-sass is deprecated and incompatible with many systems). Therefore, you need to update your code to follow this change.
NOTE! yarn build is not used to build gulp anymore, and its default behavior is to build assets using Webpack. If you want to build assets using Gulp run yarn gulp instead.
-
Follow this guide to upgrade your code when using gulp-sass this is an example:
- import sass from 'gulp-sass'; + import gulpSass from 'gulp-sass'; + import realSass from 'sass'; + const sass = gulpSass(realSass); -
Library chart.js lib has been upgraded from 2.9.3 to 3.7.1. Adjust your package.json as follows:
- "chart.js": "^2.9.3", + "chart.js": "^3.7.1",- "rollup": "^0.60.2", + "rollup": "^0.66.2",- "rollup-plugin-uglify": "^4.0.0", + "rollup-plugin-uglify": "^6.0.2",Please visit 3.x Migration Guide for more information.
Example changes we made in our codebase to adjust it to the new version of dependencies might be found here. Remember, when you face any issues while updating your dependencies you might ask for help in our Slack channel.
Webpack becomes our default build tool
1.12 comes with a long-awaited change - Webpack becomes our default build tool.
If you want to stay with Gulp, you can do it by following the steps below:
- Go to
config/packages/_sylius.yamlfile and add the following line:sylius_ui: use_webpack: false
If you decide to use Webpack, you need to follow the steps below:
- Make sure you have latest js dependencies installed (you can compare your
package.jsonfile with the one from1.12). - Make sure you have
webpack.config.jsfile, if not, you can copy it from Sylius/Sylius-Standard repository. - Run the following command
yarn encore dev
Remember! Every project is different, so you might need to adjust your code to work with Webpack.
For plugin developers - use_webpack Twig's global
We have introduced a new use_webpack global for Twig templates. It allows you to check if Webpack is declared as a build tool
to dynamically serve assets from the correct directory.
Example:
<div class="column">
<a href="{{ path('sylius_shop_homepage') }}">
{% if use_webpack %}
<img src="{{ asset('build/shop/images/logo.png', 'shop') }}" alt="Sylius logo" class="ui small image" />
{% else %}
<img src="{{ asset('assets/shop/img/logo.png') }}" alt="Sylius logo" class="ui small image" />
{% endif %}
</a>
</div>