|
| 1 | +# UPGRADE FROM 1.X TO 2.0 |
| 2 | + |
| 3 | +## General Changes |
| 4 | + |
| 5 | +1. **Support for Sylius 2.0**: The plugin is now fully compatible with Sylius 2.0 and is the recommended version to use. |
| 6 | +2. **Dropped Support for Sylius 1.X**: Applications must be upgraded to [Sylius 2.0](https://github.com/Sylius/Sylius/blob/2.0/UPGRADE-2.0.md) to continue using this plugin. |
| 7 | +3. **PHP Compatibility**: The minimum supported PHP version has been increased to **8.2**. |
| 8 | + |
| 9 | +## Structural Changes |
| 10 | + |
| 11 | +### Directory Structure Updates |
| 12 | + |
| 13 | +Following Symfony's latest recommendations, the directory structure has been updated: |
| 14 | + |
| 15 | +- `@SyliusBlacklistPlugin/Resources/assets` → `@SyliusBlacklistPlugin/assets` |
| 16 | +- `@SyliusBlacklistPlugin/Resources/config` → `@SyliusBlacklistPlugin/config` |
| 17 | +- `@SyliusBlacklistPlugin/Resources/translations` → `@SyliusBlacklistPlugin/translations` |
| 18 | +- `@SyliusBlacklistPlugin/Resources/views` → `@SyliusBlacklistPlugin/templates` |
| 19 | + |
| 20 | +## Service Modifications |
| 21 | + |
| 22 | +1. Several services have been modified to align with Sylius 2.0's structure. For example: |
| 23 | + ```xml |
| 24 | + <service id="bitbag.sylius_blacklist_plugin.form.type.automatic_blacklisting_configuration" |
| 25 | + class="BitBag\SyliusBlacklistPlugin\Form\Type\AutomaticBlacklistingConfigurationType"> |
| 26 | + <argument>%bitbag.sylius_blacklist_plugin.automatic_blacklisting_rules%</argument> |
| 27 | + <argument>%bitbag_sylius_blacklist_plugin.model.automatic_blacklisting_configuration.class%</argument> |
| 28 | + <argument>%bitbag.sylius_blacklist_plugin.form.type.validation_groups%</argument> |
| 29 | + <tag name="form.type" /> |
| 30 | + </service> |
| 31 | + |
| 32 | + <service id="sylius.form.type.checkout_address" class="Sylius\Bundle\CoreBundle\Form\Type\Checkout\AddressType"> |
| 33 | + <argument type="service" id="sylius.comparator.address" /> |
| 34 | + <argument>%sylius.model.order.class%</argument> |
| 35 | + <argument>%bitbag.sylius_blacklist_plugin.form.type.checkout_address.validation_groups%</argument> |
| 36 | + <argument type="service" id="sylius.address_comparator" /> |
| 37 | + <tag name="form.type" /> |
| 38 | + </service> |
| 39 | + |
| 40 | + <service id="bitbag.sylius_blacklist_plugin.form.type.customer_autocomplete" class="BitBag\SyliusBlacklistPlugin\Form\Type\CustomerAutocompleteType"> |
| 41 | + <argument>%sylius.model.customer.class%</argument> |
| 42 | + <tag name="form.type" /> |
| 43 | + <tag name="ux.entity_autocomplete_field" /> |
| 44 | + </service> |
| 45 | + |
| 46 | + <service id="bitbag.sylius_blacklist_plugin.state_resolver.customer" class="BitBag\SyliusBlacklistPlugin\StateResolver\CustomerStateResolver"> |
| 47 | + <argument type="service" id="sm.factory" /> |
| 48 | + <argument type="service" id="sylius.manager.customer" /> |
| 49 | + <argument type="service" id="state_machine.bitbag_sylius_blacklist_plugin_customer" /> |
| 50 | + <argument type="service" id="doctrine.orm.entity_manager" /> |
| 51 | + </service> |
| 52 | + |
| 53 | + <service id="bitbag.sylius_blacklist_plugin.twig.extension.labels.automatic_blacklisting_configuration" class="BitBag\SyliusBlacklistPlugin\Twig\AutomaticBlacklistingConfigurationLabelsExtension"> |
| 54 | + <argument>%bitbag.sylius_blacklist_plugin.automatic_blacklisting_rules%</argument> |
| 55 | + <tag name="twig.extension"/> |
| 56 | + </service> |
| 57 | + |
| 58 | + (...) |
| 59 | + ``` |
| 60 | + |
| 61 | +2. Additional service modifications (template downloaded from twig_hooks): |
| 62 | + |
| 63 | + ```xml |
| 64 | + <service id="bitbag.sylius_blacklist_plugin.twig.component.automatic_blacklisting_configuration.form" class="Sylius\Bundle\UiBundle\Twig\Component\ResourceFormComponent"> |
| 65 | + <argument type="service" id="bitbag_sylius_blacklist_plugin.repository.automatic_blacklisting_configuration" /> |
| 66 | + <argument type="service" id="form.factory" /> |
| 67 | + <argument>%bitbag_sylius_blacklist_plugin.model.automatic_blacklisting_configuration.class%</argument> |
| 68 | + <argument>BitBag\SyliusBlacklistPlugin\Form\Type\AutomaticBlacklistingConfigurationType</argument> |
| 69 | + <tag name="sylius.live_component.admin" key="sylius_admin:automatic_blacklisting_configuration:form"/> |
| 70 | + </service> |
| 71 | + |
| 72 | + <service id="bitbag.sylius_blacklist_plugin.twig.component.blacklisting_rule.form" class="Sylius\Bundle\UiBundle\Twig\Component\ResourceFormComponent"> |
| 73 | + <argument type="service" id="bitbag_sylius_blacklist_plugin.repository.blacklisting_rule" /> |
| 74 | + <argument type="service" id="form.factory" /> |
| 75 | + <argument>%bitbag_sylius_blacklist_plugin.model.blacklisting_rule.class%</argument> |
| 76 | + <argument>BitBag\SyliusBlacklistPlugin\Form\Type\BlacklistingRuleType</argument> |
| 77 | + <tag name="sylius.live_component.admin" key="sylius_admin:blacklisting_rule:form"/> |
| 78 | + </service> |
| 79 | + |
| 80 | + <service id="bitbag.sylius_blacklist_plugin.twig.component.fraud_suspicion.form" class="Sylius\Bundle\UiBundle\Twig\Component\ResourceFormComponent"> |
| 81 | + <argument type="service" id="bitbag_sylius_blacklist_plugin.repository.fraud_suspicion" /> |
| 82 | + <argument type="service" id="form.factory" /> |
| 83 | + <argument>%bitbag_sylius_blacklist_plugin.model.fraud_suspicion.class%</argument> |
| 84 | + <argument>BitBag\SyliusBlacklistPlugin\Form\Type\FraudSuspicionType</argument> |
| 85 | + <tag name="sylius.live_component.admin" key="sylius_admin:fraud_suspicion:form"/> |
| 86 | + </service> |
| 87 | + ``` |
| 88 | + |
| 89 | +3. **Container Service Visibility Changes**: The visibility of services has been set to `private` by default, following Symfony best practices. Services used in controllers and event listeners remain public where necessary. |
| 90 | + |
| 91 | + |
| 92 | +## Routing Updates |
| 93 | + |
| 94 | +1. The route **bitbag_sylius_blacklist_plugin_admin_fraud_suspicion_show** has been replaced with **sylius_admin_fraud_suspicion_show**. Update your routes configuration accordingly: |
| 95 | + |
| 96 | +```yaml |
| 97 | +sylius_admin_fraud_suspicion_show: |
| 98 | + path: /admin/fraud-suspicion/{id} |
| 99 | + controller: BitBag\SyliusBlacklistPlugin\Controller\FraudSuspicionController::showAction |
| 100 | +``` |
| 101 | +
|
| 102 | +## Admin Panel Adjustments |
| 103 | +
|
| 104 | +1. **No need to overwrite templates**: |
| 105 | + Thanks to the use of Twig Hooks and the refactoring of templates, you no longer need to overwrite templates to use plugin features. |
| 106 | +
|
| 107 | +## Twig Hook Integrations |
| 108 | +
|
| 109 | +```yaml |
| 110 | +sylius_twig_hooks: |
| 111 | + hooks: |
| 112 | + 'sylius_admin.automatic_blacklisting_configuration.create.content': |
| 113 | + form: |
| 114 | + component: 'sylius_admin:automatic_blacklisting_configuration:form' |
| 115 | + props: |
| 116 | + resource: '@=_context.resource' |
| 117 | + form: '@=_context.form' |
| 118 | + template: '@BitBagSyliusBlacklistPlugin/AutomaticBlacklistingConfiguration/Admin/form.html.twig' |
| 119 | + configuration: |
| 120 | + render_rest: false |
| 121 | +``` |
| 122 | +
|
| 123 | +More Twig Hooks are available for different contexts, including: |
| 124 | +
|
| 125 | +- `sylius_admin.automatic_blacklisting_configuration.update.content` |
| 126 | +- `sylius_admin.blacklisting_rule.create.content` |
| 127 | +- `sylius_admin.blacklisting_rule.update.content` |
| 128 | +- `sylius_admin.fraud_suspicion.create.content` |
| 129 | +- `sylius_admin.fraud_suspicion.update.content` |
| 130 | +- `sylius_admin.fraud_suspicion.show.content` |
| 131 | + |
| 132 | +## Overwritten Sylius Templates |
| 133 | + |
| 134 | +```yaml |
| 135 | +sylius_twig_hooks: |
| 136 | + hooks: |
| 137 | + 'sylius_admin.customer.update.content.form.sections#right': |
| 138 | + extra_information: |
| 139 | + template: '@BitBagSyliusBlacklistPlugin/Customer/Form/Sections/extra_information.html.twig' |
| 140 | + priority: 0 |
| 141 | +
|
| 142 | +sylius_twig_hooks: |
| 143 | + hooks: |
| 144 | + 'sylius_admin.customer.update.content.form.sections#right': |
| 145 | + extra_information: |
| 146 | + template: '@BitBagSyliusBlacklistPlugin/Customer/Form/Sections/extra_information.html.twig' |
| 147 | + priority: 0 |
| 148 | +
|
| 149 | +sylius_twig_hooks: |
| 150 | + hooks: |
| 151 | + 'sylius_admin.order.show.content.header.title_block': |
| 152 | + title: |
| 153 | + template: '@SyliusAdmin/order/show/content/header/title_block/title.html.twig' |
| 154 | + priority: 100 |
| 155 | + actions: |
| 156 | + template: '@BitBagSyliusBlacklistPlugin/Order/Show/Content/Header/Title_block/actions.html.twig' |
| 157 | + priority: 0 |
| 158 | +``` |
| 159 | + |
| 160 | +## Configuration Updates |
| 161 | + |
| 162 | +1. **Winzou State Machine Removed**: |
| 163 | + - The Winzou State Machine has been completely removed. |
| 164 | + - Instead, the **Symfony Workflow** component has been introduced for managing state transitions. |
| 165 | + - Update your configuration to use `workflow` instead of `state_machine`. |
| 166 | + |
| 167 | + Example: |
| 168 | + ```yaml |
| 169 | + framework: |
| 170 | + workflows: |
| 171 | + !php/const BitBag\SyliusBlacklistPlugin\Transitions\CustomerTransitions::GRAPH: |
| 172 | + type: state_machine |
| 173 | + marking_store: |
| 174 | + property: fraudStatus |
| 175 | + type: method |
| 176 | + supports: |
| 177 | + - BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface |
| 178 | + initial_marking: |
| 179 | + !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_NEUTRAL |
| 180 | + places: |
| 181 | + - !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_NEUTRAL |
| 182 | + - !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_BLACKLISTED |
| 183 | + - !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_WHITELISTED |
| 184 | + transitions: |
| 185 | + !php/const BitBag\SyliusBlacklistPlugin\Transitions\CustomerTransitions::TRANSITION_NEUTRALIZING_PROCESS: |
| 186 | + from: |
| 187 | + - !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_BLACKLISTED |
| 188 | + to: |
| 189 | + - !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_NEUTRAL |
| 190 | + !php/const BitBag\SyliusBlacklistPlugin\Transitions\CustomerTransitions::TRANSITION_BLACKLISTING_PROCESS: |
| 191 | + from: |
| 192 | + - !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_NEUTRAL |
| 193 | + to: |
| 194 | + - !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_BLACKLISTED |
| 195 | + !php/const BitBag\SyliusBlacklistPlugin\Transitions\CustomerTransitions::TRANSITION_WHITELISTING_PROCESS: |
| 196 | + from: |
| 197 | + - !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_NEUTRAL |
| 198 | + to: |
| 199 | + - !php/const BitBag\SyliusBlacklistPlugin\Entity\Customer\FraudStatusInterface::FRAUD_STATUS_WHITELISTED |
| 200 | + ``` |
| 201 | + |
| 202 | +## Removed Features |
| 203 | + |
| 204 | +1. **Legacy Support Removed**: |
| 205 | + - Removed compatibility layers for Sylius 1.X. |
| 206 | + - Dropped support for deprecated interfaces and methods in Sylius 2.0. |
| 207 | + |
| 208 | +## How to Upgrade |
| 209 | + |
| 210 | +1. Ensure your application is upgraded to Sylius 2.0: |
| 211 | + ```bash |
| 212 | + composer require sylius/sylius:~2.0.0 --no-update |
| 213 | + ``` |
| 214 | +2. To update the plugin, run the following command: |
| 215 | + ```bash |
| 216 | + composer require bitbag/blacklist-plugin:^2.0 --no-update |
| 217 | + ``` |
| 218 | +3. To ensure proper routing configuration, update the path in your Symfony project: |
| 219 | + |
| 220 | + Replace the following: |
| 221 | + ``` |
| 222 | + bitbag_sylius_blacklist_plugin: |
| 223 | + resource: "@BitBagSyliusBlacklistPlugin/Resources/config/routing.yaml" |
| 224 | + ``` |
| 225 | + |
| 226 | + With: |
| 227 | + ``` |
| 228 | + bitbag_sylius_blacklist_plugin: |
| 229 | + resource: "@BitBagSyliusBlacklistPlugin/config/routing.yaml" |
| 230 | + ``` |
| 231 | +3. Update your dependencies: |
| 232 | + ```bash |
| 233 | + composer update |
| 234 | + ``` |
| 235 | +4. Verify your routes and service configurations as described above. |
| 236 | +5. Verify your templates and hooks for any required adjustments. |
| 237 | + |
| 238 | +After completing these steps, your Sylius Blacklist Plugin should be fully functional with Sylius 2.0. |
| 239 | + |
0 commit comments