From 2c86ccd55f854fe7bf64d1890a939fbef8d8900d Mon Sep 17 00:00:00 2001 From: Jakob Perry Date: Thu, 16 Apr 2020 11:45:20 -0700 Subject: [PATCH 01/14] Update composer and info files to Drupal 9 and Drupal 8.7.7. --- acquia_commercemanager.info.yml | 2 +- composer.json | 1 + modules/acm/acm.info.yml | 2 +- modules/acm/composer.json | 4 ++-- .../tests/i18n_helper_configs/i18n_helper_configs.info.yml | 2 +- modules/acm_cart/acm_cart.info.yml | 2 +- modules/acm_cart/composer.json | 1 + modules/acm_checkout/acm_checkout.info.yml | 2 +- modules/acm_checkout/composer.json | 5 ++++- modules/acm_customer/acm_customer.info.yml | 2 +- modules/acm_customer/composer.json | 5 ++++- modules/acm_exception/acm_exception.info.yml | 2 +- modules/acm_exception/composer.json | 5 ++++- modules/acm_payment/acm_payment.info.yml | 2 +- modules/acm_payment/composer.json | 5 ++++- modules/acm_product/acm_product.info.yml | 2 +- modules/acm_product/composer.json | 5 ++++- modules/acm_product/config/install/views.view.products.yml | 2 +- modules/acm_promotion/acm_promotion.info.yml | 2 +- modules/acm_promotion/composer.json | 3 ++- modules/acm_sku/acm_sku.info.yml | 2 +- modules/acm_sku/composer.json | 1 + modules/acm_sku/config/optional/views.view.manage_skus.yml | 2 +- modules/acm_sku_position/acm_sku_position.info.yml | 2 +- modules/acm_sku_position/composer.json | 5 ++++- modules/acm_sku_stock/acm_sku_stock.info.yml | 2 +- modules/acm_sku_stock/composer.json | 5 ++++- 27 files changed, 50 insertions(+), 25 deletions(-) diff --git a/acquia_commercemanager.info.yml b/acquia_commercemanager.info.yml index 6b46151..aa7aff2 100644 --- a/acquia_commercemanager.info.yml +++ b/acquia_commercemanager.info.yml @@ -1,6 +1,6 @@ name: Acquia Commerce Manager type: module description: This module lays the foundation to use the Acquia Commerce Connector Service. -core: 8.x +core_version_requirement: ^8.7.7 || ^9 package: Commerce hidden: true diff --git a/composer.json b/composer.json index cdef7ba..2b36fbd 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,7 @@ "commerceguys/intl": "~1.0", "drupal/address": "^1.4.0", "drupal/consumers": "^1.4", + "drupal/core": "^8.7.7 || ^9", "drupal/field_group": "^3.0@beta", "drupal/inline_entity_form": "^1.0@rc", "drupal/key_value_field": "~1.0", diff --git a/modules/acm/acm.info.yml b/modules/acm/acm.info.yml index 62bd56f..2d93201 100644 --- a/modules/acm/acm.info.yml +++ b/modules/acm/acm.info.yml @@ -1,7 +1,7 @@ name: Acquia Commerce Manager type: module description: This module lays the foundation to use the Acquia Commerce Connector Service. -core: 8.x +core_version_requirement: ^8.7.7 || ^9 package: Commerce libraries: - acm/global_styles diff --git a/modules/acm/composer.json b/modules/acm/composer.json index 3b34857..78c8457 100644 --- a/modules/acm/composer.json +++ b/modules/acm/composer.json @@ -4,7 +4,7 @@ "description": "This module lays the foundation to use the Acquia Commerce Connector Service.", "license": "GPL-2.0-or-later", "require": { - "drupal/pcb": "~1.0", - "drupal/simple_oauth": "^3" + "drupal/core": "^8.7.7 || ^9", + "drupal/pcb": "~1.0" } } diff --git a/modules/acm/tests/i18n_helper_configs/i18n_helper_configs.info.yml b/modules/acm/tests/i18n_helper_configs/i18n_helper_configs.info.yml index 3c63bef..c378051 100644 --- a/modules/acm/tests/i18n_helper_configs/i18n_helper_configs.info.yml +++ b/modules/acm/tests/i18n_helper_configs/i18n_helper_configs.info.yml @@ -1,4 +1,4 @@ name: 'Configuration for I18nHelper' type: module package: Testing -core: 8.x +core_version_requirement: ^8.7.7 || ^9 diff --git a/modules/acm_cart/acm_cart.info.yml b/modules/acm_cart/acm_cart.info.yml index 849dbf4..a830ca8 100644 --- a/modules/acm_cart/acm_cart.info.yml +++ b/modules/acm_cart/acm_cart.info.yml @@ -1,7 +1,7 @@ name: Acquia Commerce Manager Cart type: module description: This module provides cart functionality to the Acquia Commerce Connector Service. -core: 8.x +core_version_requirement: ^8.7.7 || ^9 package: Commerce dependencies: - acquia_commercemanager:acm diff --git a/modules/acm_cart/composer.json b/modules/acm_cart/composer.json index 28cf49d..b9bf016 100644 --- a/modules/acm_cart/composer.json +++ b/modules/acm_cart/composer.json @@ -5,6 +5,7 @@ "license": "GPL-2.0-or-later", "require": { "drupal/address": "^1.4.0", + "drupal/core": "^8.7.7 || ^9", "drupal/key_value_field": "~1.0" } } diff --git a/modules/acm_checkout/acm_checkout.info.yml b/modules/acm_checkout/acm_checkout.info.yml index 9d5d37f..6836c5d 100644 --- a/modules/acm_checkout/acm_checkout.info.yml +++ b/modules/acm_checkout/acm_checkout.info.yml @@ -1,5 +1,5 @@ name: Acquia Commerce Manager Checkout type: module description: This module provides cart checkout functionality to the Acquia Commerce Connector Service. -core: 8.x +core_version_requirement: ^8.7.7 || ^9 package: Commerce diff --git a/modules/acm_checkout/composer.json b/modules/acm_checkout/composer.json index dfaa5c6..b00bc17 100644 --- a/modules/acm_checkout/composer.json +++ b/modules/acm_checkout/composer.json @@ -2,5 +2,8 @@ "name": "drupal/acm_checkout", "type": "drupal-module", "description": "This module provides cart checkout functionality to the Acquia Commerce Connector Service.", - "license": "GPL-2.0-or-later" + "license": "GPL-2.0-or-later", + "require": { + "drupal/core": "^8.7.7 || ^9" + } } diff --git a/modules/acm_customer/acm_customer.info.yml b/modules/acm_customer/acm_customer.info.yml index 4fdee85..c097ede 100644 --- a/modules/acm_customer/acm_customer.info.yml +++ b/modules/acm_customer/acm_customer.info.yml @@ -1,7 +1,7 @@ name: Acquia Commerce Manager Customer type: module description: This module provides customer profile functionality to the Acquia Commerce Connector Service. -core: 8.x +core_version_requirement: ^8.7.7 || ^9 package: Commerce dependencies: - acquia_commercemanager:acm diff --git a/modules/acm_customer/composer.json b/modules/acm_customer/composer.json index 39cc571..a2fc5d8 100644 --- a/modules/acm_customer/composer.json +++ b/modules/acm_customer/composer.json @@ -2,5 +2,8 @@ "name": "drupal/acm_customer", "type": "drupal-module", "description": "This module provides customer profile functionality to the Acquia Commerce Connector Service.", - "license": "GPL-2.0-or-later" + "license": "GPL-2.0-or-later", + "require": { + "drupal/core": "^8.7.7 || ^9" + } } diff --git a/modules/acm_exception/acm_exception.info.yml b/modules/acm_exception/acm_exception.info.yml index 64e8b41..6ce27a6 100644 --- a/modules/acm_exception/acm_exception.info.yml +++ b/modules/acm_exception/acm_exception.info.yml @@ -1,7 +1,7 @@ name: Acquia Commerce Manager API Exception type: module description: Provides configurable error messaging for API exceptions. -core: 8.x +core_version_requirement: ^8.7.7 || ^9 package: Commerce dependencies: - acquia_commercemanager:acm diff --git a/modules/acm_exception/composer.json b/modules/acm_exception/composer.json index 318754b..338808c 100644 --- a/modules/acm_exception/composer.json +++ b/modules/acm_exception/composer.json @@ -2,5 +2,8 @@ "name": "drupal/acm_exception", "type": "drupal-module", "description": "Provides configurable error messaging for API exceptions.", - "license": "GPL-2.0-or-later" + "license": "GPL-2.0-or-later", + "require": { + "drupal/core": "^8.7.7 || ^9" + } } diff --git a/modules/acm_payment/acm_payment.info.yml b/modules/acm_payment/acm_payment.info.yml index 98373ad..303167b 100644 --- a/modules/acm_payment/acm_payment.info.yml +++ b/modules/acm_payment/acm_payment.info.yml @@ -1,7 +1,7 @@ name: Acquia Commerce Manager Payment type: module description: This module provides payment functionality to the Acquia Commerce Connector Service. -core: 8.x +core_version_requirement: ^8.7.7 || ^9 package: Commerce dependencies: - acquia_commercemanager:acm diff --git a/modules/acm_payment/composer.json b/modules/acm_payment/composer.json index ea8b93d..ceec816 100644 --- a/modules/acm_payment/composer.json +++ b/modules/acm_payment/composer.json @@ -2,5 +2,8 @@ "name": "drupal/acm_payment", "type": "drupal-module", "description": "This module provides payment functionality to the Acquia Commerce Connector Service.", - "license": "GPL-2.0-or-later" + "license": "GPL-2.0-or-later", + "require": { + "drupal/core": "^8.7.7 || ^9" + } } diff --git a/modules/acm_product/acm_product.info.yml b/modules/acm_product/acm_product.info.yml index 6d6b142..dce161f 100644 --- a/modules/acm_product/acm_product.info.yml +++ b/modules/acm_product/acm_product.info.yml @@ -1,7 +1,7 @@ name: Acquia Commerce Manager Product type: module description: This module provides a product content type and views to use with the Acquia Commerce Connector Service. -core: 8.x +core_version_requirement: ^8.7.7 || ^9 package: Commerce dependencies: - drupal:node diff --git a/modules/acm_product/composer.json b/modules/acm_product/composer.json index 122adc4..bd223c2 100644 --- a/modules/acm_product/composer.json +++ b/modules/acm_product/composer.json @@ -2,5 +2,8 @@ "name": "drupal/acm_product", "type": "drupal-module", "description": "This module provides a product content type and views to use with the Acquia Commerce Connector Service.", - "license": "GPL-2.0-or-later" + "license": "GPL-2.0-or-later", + "require": { + "drupal/core": "^8.7.7 || ^9" + } } diff --git a/modules/acm_product/config/install/views.view.products.yml b/modules/acm_product/config/install/views.view.products.yml index 01fbcd6..0429055 100644 --- a/modules/acm_product/config/install/views.view.products.yml +++ b/modules/acm_product/config/install/views.view.products.yml @@ -17,7 +17,7 @@ description: '' tag: '' base_table: node_field_data base_field: nid -core: 8.x +core_version_requirement: ^8.7.7 || ^9 display: default: display_plugin: default diff --git a/modules/acm_promotion/acm_promotion.info.yml b/modules/acm_promotion/acm_promotion.info.yml index 5a7dbcb..b64996a 100644 --- a/modules/acm_promotion/acm_promotion.info.yml +++ b/modules/acm_promotion/acm_promotion.info.yml @@ -1,7 +1,7 @@ name: Acquia Commerce Manager Promotion type: module description: This module provides Promotions functionality to the Acquia Commerce Connector Service. -core: 8.x +core_version_requirement: ^8.7.7 || ^9 package: Commerce dependencies: - acquia_commercemanager:acm_sku diff --git a/modules/acm_promotion/composer.json b/modules/acm_promotion/composer.json index 3a6b9ef..6b41d0d 100644 --- a/modules/acm_promotion/composer.json +++ b/modules/acm_promotion/composer.json @@ -4,6 +4,7 @@ "description": "This module provides Promotions functionality to the Acquia Commerce Connector Service.", "license": "GPL-2.0-or-later", "require": { - "drupal/field_group": "^3.0@beta" + "drupal/core": "^8.7.7 || ^9", + "drupal/field_group": "^3.0" } } diff --git a/modules/acm_sku/acm_sku.info.yml b/modules/acm_sku/acm_sku.info.yml index f1aa411..394e48d 100644 --- a/modules/acm_sku/acm_sku.info.yml +++ b/modules/acm_sku/acm_sku.info.yml @@ -1,7 +1,7 @@ name: Acquia Commerce Manager SKU type: module description: This module provides SKU functionality to the Acquia Commerce Connector Service. -core: 8.x +core_version_requirement: ^8.7.7 || ^9 package: Commerce dependencies: - acquia_commercemanager:acm diff --git a/modules/acm_sku/composer.json b/modules/acm_sku/composer.json index 636cac6..cc153d6 100644 --- a/modules/acm_sku/composer.json +++ b/modules/acm_sku/composer.json @@ -4,6 +4,7 @@ "description": "This module provides SKU functionality to the Acquia Commerce Connector Service.", "license": "GPL-2.0-or-later", "require": { + "drupal/core": "^8.7.7 || ^9", "drupal/inline_entity_form": "^1.0@rc", "drupal/key_value_field": "~1.0" } diff --git a/modules/acm_sku/config/optional/views.view.manage_skus.yml b/modules/acm_sku/config/optional/views.view.manage_skus.yml index 2cb6f4c..52e0d89 100644 --- a/modules/acm_sku/config/optional/views.view.manage_skus.yml +++ b/modules/acm_sku/config/optional/views.view.manage_skus.yml @@ -11,7 +11,7 @@ description: '' tag: '' base_table: acm_sku_field_data base_field: id -core: 8.x +core_version_requirement: ^8.7.7 || ^9 display: default: display_plugin: default diff --git a/modules/acm_sku_position/acm_sku_position.info.yml b/modules/acm_sku_position/acm_sku_position.info.yml index 9b3260a..2d92374 100644 --- a/modules/acm_sku_position/acm_sku_position.info.yml +++ b/modules/acm_sku_position/acm_sku_position.info.yml @@ -1,7 +1,7 @@ name: Acquia Commerce Manager SKU Position type: module description: This module provides functionality to store the sku (product) position. -core: 8.x +core_version_requirement: ^8.7.7 || ^9 package: Commerce dependencies: - acquia_commercemanager:acm diff --git a/modules/acm_sku_position/composer.json b/modules/acm_sku_position/composer.json index cbf0321..8d89d16 100644 --- a/modules/acm_sku_position/composer.json +++ b/modules/acm_sku_position/composer.json @@ -2,5 +2,8 @@ "name": "drupal/acm_sku_position", "type": "drupal-module", "description": "This module provides functionality to store the sku (product) position.", - "license": "GPL-2.0-or-later" + "license": "GPL-2.0-or-later", + "require": { + "drupal/core": "^8.7.7 || ^9" + } } diff --git a/modules/acm_sku_stock/acm_sku_stock.info.yml b/modules/acm_sku_stock/acm_sku_stock.info.yml index 6167e60..c7d5bc9 100644 --- a/modules/acm_sku_stock/acm_sku_stock.info.yml +++ b/modules/acm_sku_stock/acm_sku_stock.info.yml @@ -1,7 +1,7 @@ name: Acquia Commerce SKU Stock type: module description: This module adds stock management functionality to the Acquia Commerce Connector. -core: 8.x +core_version_requirement: ^8.7.7 || ^9 package: Commerce dependencies: - acquia_commercemanager:acm diff --git a/modules/acm_sku_stock/composer.json b/modules/acm_sku_stock/composer.json index 0dff70c..5b21954 100644 --- a/modules/acm_sku_stock/composer.json +++ b/modules/acm_sku_stock/composer.json @@ -2,5 +2,8 @@ "name": "drupal/acm_sku_stock", "type": "drupal-module", "description": "This module adds stock management functionality to the Acquia Commerce Connector.", - "license": "GPL-2.0-or-later" + "license": "GPL-2.0-or-later", + "require": { + "drupal/core": "^8.7.7 || ^9" + } } From f3293a3d0a5ec89a3786ebb11896c66a9e592d9d Mon Sep 17 00:00:00 2001 From: Jakob Perry Date: Thu, 16 Apr 2020 09:44:53 -0700 Subject: [PATCH 02/14] Don't use @deprecated because its a submodule and d.o coding standards don't work with it. --- modules/acm_cart/src/CartStorage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/acm_cart/src/CartStorage.php b/modules/acm_cart/src/CartStorage.php index ad343aa..14e7454 100644 --- a/modules/acm_cart/src/CartStorage.php +++ b/modules/acm_cart/src/CartStorage.php @@ -320,7 +320,7 @@ public function updateCart($create_new = TRUE) { /** * Pushes the cart to the ecommerce app via the Connector API. * - * @deprecated Use updateCart() instead. + * Deprecated, Use updateCart() instead. * * @return null|\Drupal\acm_cart\CartInterface * Returns the cart data as sent by the ecommerce backend From f1760eaa4a45888edbac0e409d896e9ed3e31801 Mon Sep 17 00:00:00 2001 From: Jakob Perry Date: Thu, 16 Apr 2020 13:01:05 -0700 Subject: [PATCH 03/14] Add field group patch for D9 compatibility. --- .travis.yml | 17 +++++++++-------- composer.json | 3 +++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index d7390d2..9da73de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,23 +23,24 @@ env: - ORCA_PACKAGES_CONFIG_ALTER=../acquia_commercemanager/tests/packages_alter.yml - ORCA_TELEMETRY_ENABLE=TRUE +#temporarily kill other jobs... jobs: fast_finish: true include: - { name: "Static code analysis", env: ORCA_JOB=STATIC_CODE_ANALYSIS } - { name: "Deprecated code scan", env: ORCA_JOB=DEPRECATED_CODE_SCAN } - { name: "Isolated test w/ recommended package versions", env: ORCA_JOB=ISOLATED_RECOMMENDED } - - { name: "Integrated test w/ recommended package versions", env: ORCA_JOB=INTEGRATED_RECOMMENDED } - - { name: "Integrated test w/ recommended package versions & previous minor release of Drupal core", env: ORCA_JOB=CORE_PREVIOUS } - - { name: "Isolated test w/ dev package versions", env: ORCA_JOB=ISOLATED_DEV } - - { name: "Integrated test w/ dev package versions", env: ORCA_JOB=INTEGRATED_DEV } - - { name: "Integrated test w/ dev package versions & next minor dev version of Drupal core", env: ORCA_JOB=CORE_NEXT } +# - { name: "Integrated test w/ recommended package versions", env: ORCA_JOB=INTEGRATED_RECOMMENDED } +# - { name: "Integrated test w/ recommended package versions & previous minor release of Drupal core", env: ORCA_JOB=CORE_PREVIOUS } +# - { name: "Isolated test w/ dev package versions", env: ORCA_JOB=ISOLATED_DEV } +# - { name: "Integrated test w/ dev package versions", env: ORCA_JOB=INTEGRATED_DEV } +# - { name: "Integrated test w/ dev package versions & next minor dev version of Drupal core", env: ORCA_JOB=CORE_NEXT } - { name: "D9 readiness test", php: "7.3", env: ORCA_JOB=D9_READINESS} allow_failures: # Dev jobs are allowed to fail due to their inherent instability. - - env: ORCA_JOB=ISOLATED_DEV - - env: ORCA_JOB=INTEGRATED_DEV - - env: ORCA_JOB=CORE_NEXT +# - env: ORCA_JOB=ISOLATED_DEV +# - env: ORCA_JOB=INTEGRATED_DEV +# - env: ORCA_JOB=CORE_NEXT # Temporary allowances. - env: ORCA_JOB=STATIC_CODE_ANALYSIS - env: ORCA_JOB=DEPRECATED_CODE_SCAN diff --git a/composer.json b/composer.json index 2b36fbd..01a0dd9 100644 --- a/composer.json +++ b/composer.json @@ -31,6 +31,9 @@ "patches": { "drupal/simple_oauth": { "#3078547 - Merge Simple OAuth Extras in Simple OAuth": "https://www.drupal.org/files/issues/2020-04-07/3078547-install-field-definitions-43.patch" + }, + "drupal/field_group": { + "#3109552 - Field Group D9 support": "https://www.drupal.org/files/issues/2020-04-14/3109552-30.patch" } } }, From 0a2bcd264b0628cf5f31d96f6fa4c92ec6ef3dee Mon Sep 17 00:00:00 2001 From: Jakob Perry Date: Thu, 16 Apr 2020 13:17:20 -0700 Subject: [PATCH 04/14] Use field group 3.x-dev --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 01a0dd9..82f0210 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "drupal/address": "^1.4.0", "drupal/consumers": "^1.4", "drupal/core": "^8.7.7 || ^9", - "drupal/field_group": "^3.0@beta", + "drupal/field_group": "3.x-dev", "drupal/inline_entity_form": "^1.0@rc", "drupal/key_value_field": "~1.0", "drupal/pcb": "~1.0", From 77b109e21840677d36d67a09eb6c08496cce46b6 Mon Sep 17 00:00:00 2001 From: Jakob Perry Date: Tue, 5 May 2020 10:43:41 -0700 Subject: [PATCH 05/14] Use PCB 2.0 --- composer.json | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 82f0210..5120fbd 100644 --- a/composer.json +++ b/composer.json @@ -20,21 +20,12 @@ "drupal/field_group": "3.x-dev", "drupal/inline_entity_form": "^1.0@rc", "drupal/key_value_field": "~1.0", - "drupal/pcb": "~1.0", + "drupal/pcb": "^2.0", "drupal/simple_oauth": "^4" }, "extra": { "branch-alias": { "dev-8.x-1.x": "1.x-dev" - }, - "enable-patching": true, - "patches": { - "drupal/simple_oauth": { - "#3078547 - Merge Simple OAuth Extras in Simple OAuth": "https://www.drupal.org/files/issues/2020-04-07/3078547-install-field-definitions-43.patch" - }, - "drupal/field_group": { - "#3109552 - Field Group D9 support": "https://www.drupal.org/files/issues/2020-04-14/3109552-30.patch" - } } }, "minimum-stability": "dev", From 95208bbe8143936939f1ad9fc63cac15cb8b2f73 Mon Sep 17 00:00:00 2001 From: Jakob Perry Date: Wed, 4 Mar 2020 22:42:31 -0800 Subject: [PATCH 06/14] Making acm_sku D9 ready/compatible. # Conflicts: # modules/acm_sku/src/Entity/SKU.php --- modules/acm_sku/acm_sku.install | 10 ++++----- modules/acm_sku/acm_sku.services.yml | 1 + modules/acm_sku/src/AcmSkuLinkedSku.php | 15 +++++++++++-- .../src/AcquiaCommerce/SKUPluginBase.php | 16 ++++++++++++-- modules/acm_sku/src/Entity/SKU.php | 5 +++-- modules/acm_sku/src/Form/ProductSyncForm.php | 7 +++--- .../acm_sku/src/Form/SKUTypeDeleteForm.php | 14 +++++------- modules/acm_sku/src/Form/SKUTypeForm.php | 6 ++--- .../AcquiaCommerce/SKUType/Configurable.php | 4 ++-- .../Plugin/AcquiaCommerce/SKUType/Grouped.php | 4 ++-- .../Plugin/AcquiaCommerce/SKUType/Simple.php | 4 ++-- .../Plugin/AcquiaCommerce/SKUType/Variant.php | 4 ++-- .../CommerceDashboardItem/ProductStats.php | 7 +++--- .../Plugin/CommerceDashboardItem/SkuStats.php | 7 +++--- .../ProductImageLinkFormatter.php | 2 +- .../rest/resource/ProductSyncResource.php | 2 +- modules/acm_sku/src/ProductOptionsManager.php | 2 +- modules/acm_sku/src/SKUFieldsManager.php | 22 ------------------- 18 files changed, 68 insertions(+), 64 deletions(-) diff --git a/modules/acm_sku/acm_sku.install b/modules/acm_sku/acm_sku.install index a09f57e..7fc1867 100644 --- a/modules/acm_sku/acm_sku.install +++ b/modules/acm_sku/acm_sku.install @@ -289,13 +289,13 @@ function acm_sku_update_8106() { } /** - * Implements hook_update_N(). + * Update 8107 was removed because it just ran entityupdates, which no longer + * works as of Drupal 8.7. If you did not run this update prior to updating to + * 8.7, please get the earlier version of ACM, run all updates, and download the + * new version. * - * Make price, final_price and special_price non-translatable. + * Old intention: Make price, final_price and special_price non-translatable. */ -function acm_sku_update_8107() { - \Drupal::entityDefinitionUpdateManager()->applyUpdates(); -} /** * Implements hook_update_N(). diff --git a/modules/acm_sku/acm_sku.services.yml b/modules/acm_sku/acm_sku.services.yml index 865de52..53f2b1a 100644 --- a/modules/acm_sku/acm_sku.services.yml +++ b/modules/acm_sku/acm_sku.services.yml @@ -70,6 +70,7 @@ services: - '@config.factory' - '@language_manager' - '@logger.factory' + - '@datetime.time' cache.linked_skus: class: Drupal\Core\Cache\CacheInterface diff --git a/modules/acm_sku/src/AcmSkuLinkedSku.php b/modules/acm_sku/src/AcmSkuLinkedSku.php index 6133a24..02b0b78 100644 --- a/modules/acm_sku/src/AcmSkuLinkedSku.php +++ b/modules/acm_sku/src/AcmSkuLinkedSku.php @@ -4,6 +4,7 @@ use Drupal\acm\Connector\APIWrapper; use Drupal\acm_sku\Entity\SKU; +use Drupal\Component\Datetime\TimeInterface; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Language\LanguageManagerInterface; @@ -49,6 +50,13 @@ class AcmSkuLinkedSku { */ protected $loggerFactory; + /** + * Utility for manage time. + * + * @var \Drupal\Component\Datetime\TimeInterface + */ + protected $time; + /** * AcmSkuLinkedSku constructor. * @@ -62,13 +70,16 @@ class AcmSkuLinkedSku { * The language manager. * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $logger_factory * The logger factory. + * @param \Drupal\Component\Datetime\TimeInterface $time + * Utility for manage time. */ - public function __construct(APIWrapper $api_wrapper, CacheBackendInterface $cache, ConfigFactoryInterface $config_factory, LanguageManagerInterface $language_manager, LoggerChannelFactoryInterface $logger_factory) { + public function __construct(APIWrapper $api_wrapper, CacheBackendInterface $cache, ConfigFactoryInterface $config_factory, LanguageManagerInterface $language_manager, LoggerChannelFactoryInterface $logger_factory, TimeInterface $time) { $this->apiWrapper = $api_wrapper; $this->cache = $cache; $this->configFactory = $config_factory; $this->loggerFactory = $logger_factory; $this->languageManager = $language_manager; + $this->time = $time; } /** @@ -98,7 +109,7 @@ public function getLinkedskus(SKU $sku, $type = LINKED_SKU_TYPE_ALL) { $data = $type != LINKED_SKU_TYPE_ALL ? $linked_skus[$type] : $linked_skus; // Set the cache. if ($cache_lifetime = $this->configFactory->get('acm_sku.settings')->get('linked_skus_cache_max_lifetime')) { - $cache_lifetime += \Drupal::time()->getRequestTime(); + $cache_lifetime += $this->time->getRequestTime(); $this->cache->set($cache_key, $data, $cache_lifetime, ['acm_sku:' . $sku->id()]); } } diff --git a/modules/acm_sku/src/AcquiaCommerce/SKUPluginBase.php b/modules/acm_sku/src/AcquiaCommerce/SKUPluginBase.php index 74f3bed..f4ea9ce 100644 --- a/modules/acm_sku/src/AcquiaCommerce/SKUPluginBase.php +++ b/modules/acm_sku/src/AcquiaCommerce/SKUPluginBase.php @@ -9,6 +9,7 @@ use Drupal\Component\Render\FormattableMarkup; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Database\Connection; +use Drupal\Core\Messenger\MessengerInterface; use Drupal\Core\Form\FormInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Link; @@ -35,6 +36,13 @@ abstract class SKUPluginBase extends PluginBase implements SKUPluginInterface, F */ protected $connection; + /** + * Messenger service. + * + * @var \Drupal\Core\Messenger\MessengerInterface + */ + protected $messenger; + /** * Constructor. * @@ -48,11 +56,14 @@ abstract class SKUPluginBase extends PluginBase implements SKUPluginInterface, F * The factory for configuration objects. * @param \Drupal\Core\Database\Connection $connection * The current active database's master connection. + * @param \Drupal\Core\Messenger\MessengerInterface $messenger + * Messenger service. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, Connection $connection) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, Connection $connection, MessengerInterface $messenger) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->configFactory = $config_factory; $this->connection = $connection; + $this->messenger = $messenger; } /** @@ -64,7 +75,8 @@ public static function create(ContainerInterface $container, array $configuratio $plugin_id, $plugin_definition, $container->get('config.factory'), - $container->get('database') + $container->get('database'), + $container->get('messenger') ); } diff --git a/modules/acm_sku/src/Entity/SKU.php b/modules/acm_sku/src/Entity/SKU.php index 6e4eda9..708c444 100644 --- a/modules/acm_sku/src/Entity/SKU.php +++ b/modules/acm_sku/src/Entity/SKU.php @@ -8,6 +8,7 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\BaseFieldDefinition; +use Drupal\Core\File\FileSystemInterface; use Drupal\file\Entity\File; use Drupal\file\FileInterface; use Drupal\user\UserInterface; @@ -688,11 +689,11 @@ protected function downloadMediaImage(array $data) { $directory = 'public://media/' . str_replace('/' . $file_name, '', $path); // Prepare the directory. - file_prepare_directory($directory, FILE_CREATE_DIRECTORY); + \Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY); // Save the file as file entity. /** @var \Drupal\file\Entity\File $file */ - if ($file = file_save_data($file_data, $directory . '/' . $file_name, FILE_EXISTS_REPLACE)) { + if ($file = file_save_data($file_data, $directory . '/' . $file_name, FileSystemInterface::EXISTS_REPLACE)) { \Drupal::logger('acm_sku') ->debug('File @url downloaded to @file for SKU @sku', [ diff --git a/modules/acm_sku/src/Form/ProductSyncForm.php b/modules/acm_sku/src/Form/ProductSyncForm.php index 7b31d61..3be928f 100644 --- a/modules/acm_sku/src/Form/ProductSyncForm.php +++ b/modules/acm_sku/src/Form/ProductSyncForm.php @@ -161,12 +161,12 @@ public function submitForm(array &$form, FormStateInterface $form_state) { case 'Synchronize Categories': $category_vid = $this->connectorConfig->get('category_vid'); $this->catManager->synchronizeTree($category_vid); - drupal_set_message('Category Synchronization Complete.', 'status'); + $this->messenger->addStatus($this->t('Category Synchronization Complete.')); break; case 'Synchronize Products (async)': $this->ingestApi->productFullSync(); - drupal_set_message('Product Synchronization Processing...', 'status'); + $this->messenger->addStatus($this->t('Product Synchronization Processing...')); break; case 'Synchronize Products (sync)': @@ -187,7 +187,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $drupalMessage .= "Product Synchronization Complete (" . $acm_uuid . "). \n"; } - drupal_set_message($drupalMessage, 'status'); + $this->messenger->addStatus($drupalMessage); + break; } } diff --git a/modules/acm_sku/src/Form/SKUTypeDeleteForm.php b/modules/acm_sku/src/Form/SKUTypeDeleteForm.php index a04aca1..40ed7fa 100644 --- a/modules/acm_sku/src/Form/SKUTypeDeleteForm.php +++ b/modules/acm_sku/src/Form/SKUTypeDeleteForm.php @@ -38,14 +38,12 @@ public function getConfirmText() { public function submitForm(array &$form, FormStateInterface $form_state) { $this->entity->delete(); - drupal_set_message( - $this->t('content @type: deleted @label.', - [ - '@type' => $this->entity->bundle(), - '@label' => $this->entity->label(), - ] - ) - ); + $this->messenger()->addStatus($this->t('content @type: deleted @label.', + [ + '@type' => $this->entity->bundle(), + '@label' => $this->entity->label(), + ] + )); $form_state->setRedirectUrl($this->getCancelUrl()); } diff --git a/modules/acm_sku/src/Form/SKUTypeForm.php b/modules/acm_sku/src/Form/SKUTypeForm.php index c227507..69d42ee 100644 --- a/modules/acm_sku/src/Form/SKUTypeForm.php +++ b/modules/acm_sku/src/Form/SKUTypeForm.php @@ -63,18 +63,18 @@ public function save(array $form, FormStateInterface $form_state) { switch ($status) { case SAVED_NEW: - drupal_set_message($this->t('Created the %label SKU type.', [ + $this->messenger->addStatus($this->t('Created the %label SKU type.', [ '%label' => $sku_type->label(), ])); break; default: - drupal_set_message($this->t('Saved the %label SKU type.', [ + $this->messenger->addStatus($this->t('Saved the %label SKU type.', [ '%label' => $sku_type->label(), ])); } - $form_state->setRedirectUrl($sku_type->urlInfo('collection')); + $form_state->setRedirectUrl($sku_type->toUrl('collection')); } } diff --git a/modules/acm_sku/src/Plugin/AcquiaCommerce/SKUType/Configurable.php b/modules/acm_sku/src/Plugin/AcquiaCommerce/SKUType/Configurable.php index 32598ad..3599091 100644 --- a/modules/acm_sku/src/Plugin/AcquiaCommerce/SKUType/Configurable.php +++ b/modules/acm_sku/src/Plugin/AcquiaCommerce/SKUType/Configurable.php @@ -298,7 +298,7 @@ public function addToCartSubmit(array &$form, FormStateInterface $form_state) { // Call above is to create cart if empty, we except a new or old cart here // and it can be empty if server is not working or in maintenance mode. if (empty($cart)) { - drupal_set_message(t('An error occured, please try again.'), 'error'); + $this->messenger->addError(t('An error occured, please try again.')); $e = new \Exception(acm_api_down_global_error_message(), APIWrapper::API_DOWN_ERROR_CODE); // Dispatch event so action can be taken. $dispatcher = \Drupal::service('event_dispatcher'); @@ -330,7 +330,7 @@ public function addToCartSubmit(array &$form, FormStateInterface $form_state) { implode(', ', $label_parts) ); - drupal_set_message( + $this->messenger->addStatus( t('Added @quantity of @name to the cart.', [ '@quantity' => $quantity, diff --git a/modules/acm_sku/src/Plugin/AcquiaCommerce/SKUType/Grouped.php b/modules/acm_sku/src/Plugin/AcquiaCommerce/SKUType/Grouped.php index 80ed588..ee64897 100644 --- a/modules/acm_sku/src/Plugin/AcquiaCommerce/SKUType/Grouped.php +++ b/modules/acm_sku/src/Plugin/AcquiaCommerce/SKUType/Grouped.php @@ -81,7 +81,7 @@ public function addToCartSubmit(array &$form, FormStateInterface $form_state) { if ($quantity > 0) { $cartStorage->addItemToCart($sku, $quantity); - drupal_set_message( + $this->messenger->addStatus( t('Added @quantity of @name to the cart.', [ '@quantity' => $quantity, @@ -94,7 +94,7 @@ public function addToCartSubmit(array &$form, FormStateInterface $form_state) { } if ($added == 0) { - drupal_set_message(t('Please select a quantity greater than 0.'), 'error'); + $this->messenger->addError(t('Please select a quantity greater than 0.')); } try { diff --git a/modules/acm_sku/src/Plugin/AcquiaCommerce/SKUType/Simple.php b/modules/acm_sku/src/Plugin/AcquiaCommerce/SKUType/Simple.php index 386d1d7..016307c 100644 --- a/modules/acm_sku/src/Plugin/AcquiaCommerce/SKUType/Simple.php +++ b/modules/acm_sku/src/Plugin/AcquiaCommerce/SKUType/Simple.php @@ -90,7 +90,7 @@ public function addToCartSubmit(array &$form, FormStateInterface $form_state) { // Call above is to create cart if empty, we except a new or old cart here // and it can be empty if server is not working or in maintenance mode. if (empty($cart)) { - drupal_set_message(t('An error occured, please try again.'), 'error'); + $this->messenger->addError(t('An error occured, please try again.')); $e = new \Exception(acm_api_down_global_error_message(), APIWrapper::API_DOWN_ERROR_CODE); // Dispatch event so action can be taken. $dispatcher = \Drupal::service('event_dispatcher'); @@ -103,7 +103,7 @@ public function addToCartSubmit(array &$form, FormStateInterface $form_state) { $sku = $sku_entity->getSku(); $quantity = $form_state->getValue('quantity'); - drupal_set_message( + $this->messenger->addStatus( t('Added @quantity of @name to the cart.', [ '@quantity' => $quantity, diff --git a/modules/acm_sku/src/Plugin/AcquiaCommerce/SKUType/Variant.php b/modules/acm_sku/src/Plugin/AcquiaCommerce/SKUType/Variant.php index 004c683..73a6feb 100644 --- a/modules/acm_sku/src/Plugin/AcquiaCommerce/SKUType/Variant.php +++ b/modules/acm_sku/src/Plugin/AcquiaCommerce/SKUType/Variant.php @@ -300,7 +300,7 @@ public function addToCartSubmit(array &$form, FormStateInterface $form_state) { } if (!$selected_sku) { - drupal_set_message(t('The product you configured is not available.'), 'error'); + $this->messenger->addError(t('The product you configured is not available.')); return; } @@ -317,7 +317,7 @@ public function addToCartSubmit(array &$form, FormStateInterface $form_state) { try { $cartStorage->addItemToCart($selected_sku, $quantity); - drupal_set_message( + $this->messenger->addStatus( t('Added @quantity of @name to the cart.', [ '@quantity' => $quantity, diff --git a/modules/acm_sku/src/Plugin/CommerceDashboardItem/ProductStats.php b/modules/acm_sku/src/Plugin/CommerceDashboardItem/ProductStats.php index 3a6a1d0..405a661 100644 --- a/modules/acm_sku/src/Plugin/CommerceDashboardItem/ProductStats.php +++ b/modules/acm_sku/src/Plugin/CommerceDashboardItem/ProductStats.php @@ -4,6 +4,7 @@ use Drupal\acm\CommerceDashboardItemBase; use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Entity\EntityTypeManager; use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -37,9 +38,9 @@ class ProductStats extends CommerceDashboardItemBase { /** * {@inheritdoc} */ - public function __construct(array $configuration, string $plugin_id, $plugin_definition, QueryFactory $entity_query, ConfigFactoryInterface $config_factory) { + public function __construct(array $configuration, string $plugin_id, $plugin_definition, EntityTypeManager $entity_type_manager, ConfigFactoryInterface $config_factory) { parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->entityQuery = $entity_query->get('node'); + $this->entityQuery = $entity_type_manager->getStorage('node')->getQuery(); $this->configFactory = $config_factory; } @@ -51,7 +52,7 @@ public static function create(ContainerInterface $container, array $configuratio $configuration, $plugin_id, $plugin_definition, - $container->get('entity.query'), + $container->get('entity_type.manager'), $container->get('config.factory') ); } diff --git a/modules/acm_sku/src/Plugin/CommerceDashboardItem/SkuStats.php b/modules/acm_sku/src/Plugin/CommerceDashboardItem/SkuStats.php index d872381..1f2eb58 100644 --- a/modules/acm_sku/src/Plugin/CommerceDashboardItem/SkuStats.php +++ b/modules/acm_sku/src/Plugin/CommerceDashboardItem/SkuStats.php @@ -3,6 +3,7 @@ namespace Drupal\acm_sku\Plugin\CommerceDashboardItem; use Drupal\acm\CommerceDashboardItemBase; +use Drupal\Core\Entity\EntityTypeManager; use Drupal\Core\Entity\Query\QueryFactory; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -28,9 +29,9 @@ class SkuStats extends CommerceDashboardItemBase { /** * {@inheritdoc} */ - public function __construct(array $configuration, string $plugin_id, $plugin_definition, QueryFactory $entity_query) { + public function __construct(array $configuration, string $plugin_id, $plugin_definition, EntityTypeManager $entity_type_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->entityQuery = $entity_query->get('acm_sku'); + $this->entityQuery = $entity_type_manager->getStorage('acm_sku')->getQuery(); } /** @@ -41,7 +42,7 @@ public static function create(ContainerInterface $container, array $configuratio $configuration, $plugin_id, $plugin_definition, - $container->get('entity.query') + $container->get('entity_type.manager') ); } diff --git a/modules/acm_sku/src/Plugin/Field/FieldFormatter/ProductImageLinkFormatter.php b/modules/acm_sku/src/Plugin/Field/FieldFormatter/ProductImageLinkFormatter.php index 48dcdf2..5c38c92 100644 --- a/modules/acm_sku/src/Plugin/Field/FieldFormatter/ProductImageLinkFormatter.php +++ b/modules/acm_sku/src/Plugin/Field/FieldFormatter/ProductImageLinkFormatter.php @@ -38,7 +38,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) { $node_entity = \Drupal::entityTypeManager()->getStorage('node')->load($nid); - $url = $node_entity->urlInfo(); + $url = $node_entity->toUrl(); foreach ($elements as &$element) { if (!is_null($element['#url'])) { diff --git a/modules/acm_sku/src/Plugin/rest/resource/ProductSyncResource.php b/modules/acm_sku/src/Plugin/rest/resource/ProductSyncResource.php index 55d9afd..bf632b7 100644 --- a/modules/acm_sku/src/Plugin/rest/resource/ProductSyncResource.php +++ b/modules/acm_sku/src/Plugin/rest/resource/ProductSyncResource.php @@ -134,7 +134,7 @@ public function post(array $products) { public function errorHandler(int $error_number, string $error_message) { switch ($error_number) { case E_RECOVERABLE_ERROR: - throw new Exception($error_message, $error_number); + throw new \Exception($error_message, $error_number); } } diff --git a/modules/acm_sku/src/ProductOptionsManager.php b/modules/acm_sku/src/ProductOptionsManager.php index fc5887b..cda25b8 100644 --- a/modules/acm_sku/src/ProductOptionsManager.php +++ b/modules/acm_sku/src/ProductOptionsManager.php @@ -130,7 +130,7 @@ public function loadProductOptionByOptionId($attribute_code, $option_id, $langco * {@inheritdoc} */ public function createProductOptionWrapper($langcode, $option_id, $option_value, $attribute_id, $attribute_code, $weight) { - return $this->createProductOption(); + return $this->createProductOption($langcode, $option_id, $option_value, $attribute_id, $attribute_code, $weight); } /** diff --git a/modules/acm_sku/src/SKUFieldsManager.php b/modules/acm_sku/src/SKUFieldsManager.php index 34d94ec..c13e297 100644 --- a/modules/acm_sku/src/SKUFieldsManager.php +++ b/modules/acm_sku/src/SKUFieldsManager.php @@ -142,7 +142,6 @@ public function removeField($field_code) { $config->setData($fields)->save(); $this->entityTypeManager->clearCachedDefinitions(); - $this->entityDefinitionUpdateManager->applyUpdates(); $fields_removed = [ $field_code => $field, @@ -188,29 +187,8 @@ public function updateFieldMetaInfo($field_code, array $field) { } } - // Need to apply entity updates for following. - $apply_updates = FALSE; - $field_labels_info = [ - 'label', - 'description', - 'visible_view', - 'visible_form', - 'weight', - ]; - - foreach ($field_labels_info as $info) { - if (isset($field[$info]) && $field['type'] != $existing_fields[$field_code]['type']) { - $apply_updates = TRUE; - break; - } - } - $existing_fields[$field_code] = array_replace($existing_fields[$field_code], $field); $config->setData($existing_fields)->save(); - - if ($apply_updates) { - $this->entityDefinitionUpdateManager->applyUpdates(); - } } /** From d5ce9b735202c40dd947f47a24f7da749326ba26 Mon Sep 17 00:00:00 2001 From: Jakob Perry Date: Thu, 16 Apr 2020 09:36:15 -0700 Subject: [PATCH 07/14] PHPCS Code Cleanup. # Conflicts: # modules/acm_cart/composer.json # modules/acm_cart/src/CartStorage.php --- modules/acm/src/Controller/CommerceUserController.php | 1 - modules/acm_sku/src/AcquiaCommerce/SKUPluginBase.php | 2 +- modules/acm_sku/src/Commands/AcmSkuDrushCommands.php | 2 -- .../acm_sku/src/Plugin/CommerceDashboardItem/ProductStats.php | 1 - modules/acm_sku/src/Plugin/CommerceDashboardItem/SkuStats.php | 1 - modules/acm_sku/src/SKUFieldsManager.php | 4 +++- 6 files changed, 4 insertions(+), 7 deletions(-) diff --git a/modules/acm/src/Controller/CommerceUserController.php b/modules/acm/src/Controller/CommerceUserController.php index 94fde29..f7b3b91 100644 --- a/modules/acm/src/Controller/CommerceUserController.php +++ b/modules/acm/src/Controller/CommerceUserController.php @@ -8,7 +8,6 @@ use Drupal\acm\User\AccountProxyInterface; use Drupal\acm\User\CommerceUserSession; use Drupal\acm_cart\CartStorageInterface; -use Drupal\Component\Utility\Crypt; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Datetime\DateFormatterInterface; use Drupal\user\UserAuthInterface; diff --git a/modules/acm_sku/src/AcquiaCommerce/SKUPluginBase.php b/modules/acm_sku/src/AcquiaCommerce/SKUPluginBase.php index f4ea9ce..c207d83 100644 --- a/modules/acm_sku/src/AcquiaCommerce/SKUPluginBase.php +++ b/modules/acm_sku/src/AcquiaCommerce/SKUPluginBase.php @@ -9,10 +9,10 @@ use Drupal\Component\Render\FormattableMarkup; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Database\Connection; -use Drupal\Core\Messenger\MessengerInterface; use Drupal\Core\Form\FormInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Link; +use Drupal\Core\Messenger\MessengerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\node\Entity\Node; use Symfony\Component\DependencyInjection\ContainerInterface; diff --git a/modules/acm_sku/src/Commands/AcmSkuDrushCommands.php b/modules/acm_sku/src/Commands/AcmSkuDrushCommands.php index 5a33823..b46a1ae 100644 --- a/modules/acm_sku/src/Commands/AcmSkuDrushCommands.php +++ b/modules/acm_sku/src/Commands/AcmSkuDrushCommands.php @@ -13,9 +13,7 @@ use Drupal\Core\Cache\CacheTagsInvalidatorInterface; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Database\Connection; -use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; -use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Logger\LoggerChannelFactoryInterface; diff --git a/modules/acm_sku/src/Plugin/CommerceDashboardItem/ProductStats.php b/modules/acm_sku/src/Plugin/CommerceDashboardItem/ProductStats.php index 405a661..cc4b90b 100644 --- a/modules/acm_sku/src/Plugin/CommerceDashboardItem/ProductStats.php +++ b/modules/acm_sku/src/Plugin/CommerceDashboardItem/ProductStats.php @@ -5,7 +5,6 @@ use Drupal\acm\CommerceDashboardItemBase; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\EntityTypeManager; -use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; diff --git a/modules/acm_sku/src/Plugin/CommerceDashboardItem/SkuStats.php b/modules/acm_sku/src/Plugin/CommerceDashboardItem/SkuStats.php index 1f2eb58..4800241 100644 --- a/modules/acm_sku/src/Plugin/CommerceDashboardItem/SkuStats.php +++ b/modules/acm_sku/src/Plugin/CommerceDashboardItem/SkuStats.php @@ -4,7 +4,6 @@ use Drupal\acm\CommerceDashboardItemBase; use Drupal\Core\Entity\EntityTypeManager; -use Drupal\Core\Entity\Query\QueryFactory; use Symfony\Component\DependencyInjection\ContainerInterface; /** diff --git a/modules/acm_sku/src/SKUFieldsManager.php b/modules/acm_sku/src/SKUFieldsManager.php index c13e297..e3ff54c 100644 --- a/modules/acm_sku/src/SKUFieldsManager.php +++ b/modules/acm_sku/src/SKUFieldsManager.php @@ -6,9 +6,9 @@ use Drupal\Core\Entity\EntityDefinitionUpdateManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; -use Psr\Log\LoggerInterface; use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\StringTranslation\TranslatableMarkup; +use Psr\Log\LoggerInterface; /** * Class SKUFieldsManager. @@ -317,6 +317,7 @@ public function getFieldDefinitionFromInfo(array $field_info, $weight = 10) { ]); } break; + case 'text_long': $fieldDefinition = BaseFieldDefinition::create('text_long'); if ($field_info['visible_view']) { @@ -333,6 +334,7 @@ public function getFieldDefinitionFromInfo(array $field_info, $weight = 10) { ]); } break; + } // Check if we don't have the field type defined yet. if (empty($fieldDefinition)) { From e3f721aeb7e526e6f438f12240862cbfed60037e Mon Sep 17 00:00:00 2001 From: Jakob Perry Date: Thu, 16 Apr 2020 09:52:08 -0700 Subject: [PATCH 08/14] Include facets, remove deprecated behat interface. --- features/bootstrap/FeatureContext.php | 2 +- modules/acm_sku/composer.json | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/features/bootstrap/FeatureContext.php b/features/bootstrap/FeatureContext.php index c33a90e..cc11ed6 100644 --- a/features/bootstrap/FeatureContext.php +++ b/features/bootstrap/FeatureContext.php @@ -17,7 +17,7 @@ /** * Defines application features from the specific context. */ -class FeatureContext extends RawDrupalContext implements SnippetAcceptingContext { +class FeatureContext extends RawDrupalContext { private $simple_product; diff --git a/modules/acm_sku/composer.json b/modules/acm_sku/composer.json index cc153d6..3d899ac 100644 --- a/modules/acm_sku/composer.json +++ b/modules/acm_sku/composer.json @@ -6,6 +6,9 @@ "require": { "drupal/core": "^8.7.7 || ^9", "drupal/inline_entity_form": "^1.0@rc", - "drupal/key_value_field": "~1.0" + "drupal/key_value_field": "^1.0" + }, + "require-dev": { + "drupal/facets": "^1.0" } } From 71ea7cf9ec0800cacab69ec4438d59c40bf40331 Mon Sep 17 00:00:00 2001 From: Jakob Perry Date: Thu, 16 Apr 2020 10:27:00 -0700 Subject: [PATCH 09/14] Update composer requirements. # Conflicts: # modules/acm/composer.json # modules/acm_promotion/composer.json --- modules/acm/composer.json | 3 ++- modules/acm_promotion/composer.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/acm/composer.json b/modules/acm/composer.json index 78c8457..8202b5f 100644 --- a/modules/acm/composer.json +++ b/modules/acm/composer.json @@ -5,6 +5,7 @@ "license": "GPL-2.0-or-later", "require": { "drupal/core": "^8.7.7 || ^9", - "drupal/pcb": "~1.0" + "drupal/pcb": "~2.0", + "drupal/simple_oauth": "^4.0" } } diff --git a/modules/acm_promotion/composer.json b/modules/acm_promotion/composer.json index 6b41d0d..3107b14 100644 --- a/modules/acm_promotion/composer.json +++ b/modules/acm_promotion/composer.json @@ -5,6 +5,6 @@ "license": "GPL-2.0-or-later", "require": { "drupal/core": "^8.7.7 || ^9", - "drupal/field_group": "^3.0" + "drupal/field_group": "3.x-dev" } } From 80608612e718ca0a2857340576d2bb497c579cc8 Mon Sep 17 00:00:00 2001 From: Jakob Perry Date: Thu, 14 May 2020 22:09:09 -0700 Subject: [PATCH 10/14] Additional D9 pieces. --- modules/acm/composer.json | 2 +- modules/acm_sku/acm_sku.install | 19 ++++++++++++++++ modules/acm_sku/drush.services.yml | 2 -- .../src/Commands/AcmSkuDrushCommands.php | 22 ------------------- modules/acm_sku/src/Entity/SKUType.php | 4 ++++ 5 files changed, 24 insertions(+), 25 deletions(-) diff --git a/modules/acm/composer.json b/modules/acm/composer.json index 8202b5f..9e337d1 100644 --- a/modules/acm/composer.json +++ b/modules/acm/composer.json @@ -5,7 +5,7 @@ "license": "GPL-2.0-or-later", "require": { "drupal/core": "^8.7.7 || ^9", - "drupal/pcb": "~2.0", + "drupal/pcb": "^2.0", "drupal/simple_oauth": "^4.0" } } diff --git a/modules/acm_sku/acm_sku.install b/modules/acm_sku/acm_sku.install index 7fc1867..dbd3129 100644 --- a/modules/acm_sku/acm_sku.install +++ b/modules/acm_sku/acm_sku.install @@ -87,6 +87,25 @@ function acm_sku_uninstall() { } $role->save(); } + + // Remove configuration + /** @var \Drupal\Core\Config\ConfigFactoryInterface $configFactory */ + $configFactory = \Drupal::configFactory(); + $logger = \Drupal::logger('acm_sku'); + + $configNames = [ + 'acm_sku.configurable_form_settings', + 'acm_sku.settings', + ]; + + foreach ($configNames as $configName) { + try { + $configFactory->getEditable($configName)->delete(); + } + catch (\Exception $e) { + $logger->warning(sprintf('Unable to uninstall config: %s.', $configName)); + } + } } /** diff --git a/modules/acm_sku/drush.services.yml b/modules/acm_sku/drush.services.yml index 1178c34..96a6006 100644 --- a/modules/acm_sku/drush.services.yml +++ b/modules/acm_sku/drush.services.yml @@ -10,8 +10,6 @@ services: - '@logger.factory' - '@database' - '@entity_type.manager' - - '@entity.query' - - '@entity.manager' - '@language_manager' - '@module_handler' - '@cache.linked_skus' diff --git a/modules/acm_sku/src/Commands/AcmSkuDrushCommands.php b/modules/acm_sku/src/Commands/AcmSkuDrushCommands.php index b46a1ae..07af673 100644 --- a/modules/acm_sku/src/Commands/AcmSkuDrushCommands.php +++ b/modules/acm_sku/src/Commands/AcmSkuDrushCommands.php @@ -79,20 +79,6 @@ class AcmSkuDrushCommands extends DrushCommands { */ private $entityTypeManager; - /** - * Query Factory. - * - * @var \Drupal\Core\Entity\Query\QueryFactory - */ - private $queryFactory; - - /** - * Entity Manager. - * - * @var \Drupal\Core\Entity\EntityManagerInterface - */ - private $entityManager; - /** * Language Manager. * @@ -161,10 +147,6 @@ class AcmSkuDrushCommands extends DrushCommands { * Database Connection. * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * Entity Type Manager. - * @param \Drupal\Core\Entity\Query\QueryFactory $query_factory - * Query Factory. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * Entity Manager. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * Language Manager. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler @@ -184,8 +166,6 @@ public function __construct(APIWrapperInterface $api_wrapper, LoggerChannelFactoryInterface $logger_factory, Connection $connection, EntityTypeManagerInterface $entity_type_manager, - QueryFactory $query_factory, - EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager, ModuleHandlerInterface $module_handler, CacheBackendInterface $linked_sku_cache, @@ -201,8 +181,6 @@ public function __construct(APIWrapperInterface $api_wrapper, $this->logger = $logger_factory->get('AcmSkuDrushCommands'); $this->connection = $connection; $this->entityTypeManager = $entity_type_manager; - $this->queryFactory = $query_factory; - $this->entityManager = $entity_manager; $this->languageManager = $language_manager; $this->moduleHandler = $module_handler; $this->linkedSkuCache = $linked_sku_cache; diff --git a/modules/acm_sku/src/Entity/SKUType.php b/modules/acm_sku/src/Entity/SKUType.php index 30ce9eb..11c8f82 100644 --- a/modules/acm_sku/src/Entity/SKUType.php +++ b/modules/acm_sku/src/Entity/SKUType.php @@ -27,6 +27,10 @@ * "id" = "id", * "label" = "label", * }, + * config_export = { + * "id", + * "label", + * }, * links = { * "canonical" = "/admin/commerce/config/sku/{acm_sku_type}", * "add-form" = "/admin/commerce/config/sku/add", From 3dfbac6441e204ab53f629e40d2499dba9ff21c2 Mon Sep 17 00:00:00 2001 From: Jakob Perry Date: Thu, 14 May 2020 22:36:27 -0700 Subject: [PATCH 11/14] Fix fatal testing syntax failures. --- modules/acm/tests/src/Unit/DatabaseSessionStoreTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/acm/tests/src/Unit/DatabaseSessionStoreTest.php b/modules/acm/tests/src/Unit/DatabaseSessionStoreTest.php index 748507e..c872f2d 100644 --- a/modules/acm/tests/src/Unit/DatabaseSessionStoreTest.php +++ b/modules/acm/tests/src/Unit/DatabaseSessionStoreTest.php @@ -29,7 +29,7 @@ class DatabaseSessionStoreTest extends PrivateTempStoreTest { /** * The user temp store. * - * @var \Drupal\user\DatabaseSessionStore + * @var \Drupal\acm\DatabaseSessionStore */ protected $tempStore; @@ -64,7 +64,7 @@ class DatabaseSessionStoreTest extends PrivateTempStoreTest { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp():void { parent::setUp(); $this->keyValue = $this->getMock('Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface'); From 89444bdbd9f404f6b2460ccbd533cb9356d53959 Mon Sep 17 00:00:00 2001 From: Jakob Perry Date: Thu, 14 May 2020 22:50:17 -0700 Subject: [PATCH 12/14] D9 test fixes. --- .../tests/src/Unit/DatabaseSessionStoreTest.php | 16 ++++++++-------- .../acm/tests/src/Unit/PhpSessionStoreTest.php | 2 +- .../acm_cart/tests/src/Unit/CartStorageTest.php | 12 ++++++------ .../tests/src/Functional/CategoryManagerTest.php | 6 ++++++ .../tests/src/Functional/ProductManagerTest.php | 5 +++++ .../tests/src/Functional/StockManagerTest.php | 6 ++++++ 6 files changed, 32 insertions(+), 15 deletions(-) diff --git a/modules/acm/tests/src/Unit/DatabaseSessionStoreTest.php b/modules/acm/tests/src/Unit/DatabaseSessionStoreTest.php index c872f2d..26d0045 100644 --- a/modules/acm/tests/src/Unit/DatabaseSessionStoreTest.php +++ b/modules/acm/tests/src/Unit/DatabaseSessionStoreTest.php @@ -67,9 +67,9 @@ class DatabaseSessionStoreTest extends PrivateTempStoreTest { protected function setUp():void { parent::setUp(); - $this->keyValue = $this->getMock('Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface'); - $this->lock = $this->getMock('Drupal\Core\Lock\LockBackendInterface'); - $this->currentUser = $this->getMock('Drupal\acm\User\AccountProxyInterface'); + $this->keyValue = $this->createMock('Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface'); + $this->lock = $this->createMock('Drupal\Core\Lock\LockBackendInterface'); + $this->currentUser = $this->createMock('Drupal\acm\User\AccountProxyInterface'); $this->currentUser->expects($this->any()) ->method('id') ->willReturn(1); @@ -102,7 +102,7 @@ public function testGetWithDefault() { ->with('1:test') ->willReturn(NULL); - $current_user = $this->getMock('Drupal\acm\User\AccountProxyInterface'); + $current_user = $this->createMock('Drupal\acm\User\AccountProxyInterface'); $tempStore = new MockDatabaseSessionStore($this->keyValue, $this->lock, $current_user, $this->requestStack); $this->assertNull($tempStore->get('test')); @@ -115,7 +115,7 @@ public function testGetWithDefault() { * @covers ::get */ public function testGetWithNoCurrentUser() { - $current_user = $this->getMock('Drupal\acm\User\AccountProxyInterface'); + $current_user = $this->createMock('Drupal\acm\User\AccountProxyInterface'); $current_user->expects($this->any()) ->method('getAccount') @@ -136,7 +136,7 @@ public function testGetWithNoCurrentUser() { * @covers ::get */ public function testGetWithCurrentUserWithNoPreviousAnonSession() { - $current_user = $this->getMock('Drupal\acm\User\AccountProxyInterface'); + $current_user = $this->createMock('Drupal\acm\User\AccountProxyInterface'); $current_uid = 3; $current_user->expects($this->any()) @@ -170,7 +170,7 @@ public function testGetWithCurrentUserWithNoPreviousAnonSession() { * @covers ::get */ public function testGetWithCurrentUserWithPreviousAnonSession() { - $current_user = $this->getMock('Drupal\acm\User\AccountProxyInterface'); + $current_user = $this->createMock('Drupal\acm\User\AccountProxyInterface'); $current_uid = 3; $current_user->expects($this->any()) @@ -211,7 +211,7 @@ public function testGetWithCurrentUserWithPreviousAnonSession() { * @covers ::get */ public function testGetWithCurrentUserWithPreviousAnonSessionAndNoReference() { - $current_user = $this->getMock('Drupal\acm\User\AccountProxyInterface'); + $current_user = $this->createMock('Drupal\acm\User\AccountProxyInterface'); $current_uid = 3; $this->lock->expects($this->once()) diff --git a/modules/acm/tests/src/Unit/PhpSessionStoreTest.php b/modules/acm/tests/src/Unit/PhpSessionStoreTest.php index 9091b70..61ad56a 100644 --- a/modules/acm/tests/src/Unit/PhpSessionStoreTest.php +++ b/modules/acm/tests/src/Unit/PhpSessionStoreTest.php @@ -28,7 +28,7 @@ class PhpSessionStoreTest extends UnitTestCase { protected function setUp() { parent::setUp(); - $this->session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface'); + $this->session = $this->createMock('Symfony\Component\HttpFoundation\Session\SessionInterface'); $this->tempStore = new PhpSessionStore($this->session); } diff --git a/modules/acm_cart/tests/src/Unit/CartStorageTest.php b/modules/acm_cart/tests/src/Unit/CartStorageTest.php index 2254b77..bf52177 100644 --- a/modules/acm_cart/tests/src/Unit/CartStorageTest.php +++ b/modules/acm_cart/tests/src/Unit/CartStorageTest.php @@ -69,8 +69,8 @@ class CartStorageTest extends UnitTestCase { protected function setUp() { parent::setUp(); - $this->session = $this->getMock('Drupal\acm\SessionStoreInterface'); - $this->logger = $this->getMock('Drupal\Core\Logger\LoggerChannelFactoryInterface'); + $this->session = $this->createMock('Drupal\acm\SessionStoreInterface'); + $this->logger = $this->createMock('Drupal\Core\Logger\LoggerChannelFactoryInterface'); $this->eventDispatcher = new EventDispatcher(); $this->apiWrapper = new MockAPIWrapper(); @@ -91,7 +91,7 @@ protected function setUp() { return $m->getName(); }, (new \ReflectionClass($interface))->getMethods()); $methods[] = 'getCartItemsCount'; - $mock_cart = $this->getMock($interface, $methods); + $mock_cart = $this->createMock($interface, $methods); $mock_cart->cart = $cart; $mock_cart->expects($this->any()) ->method('id') @@ -185,7 +185,7 @@ public function testClearCart() { * @covers ::loadCart */ public function testLoadCartWithCartInSession() { - $session = $this->getMock('Drupal\acm\SessionStoreInterface'); + $session = $this->createMock('Drupal\acm\SessionStoreInterface'); $session->expects($this->at(0)) ->method('get') @@ -208,7 +208,7 @@ public function testLoadCartWithCartInSession() { * @covers ::loadCart */ public function testLoadCartNoCartInSession() { - $session = $this->getMock('Drupal\acm\SessionStoreInterface'); + $session = $this->createMock('Drupal\acm\SessionStoreInterface'); $session->expects($this->exactly(1)) ->method('get') @@ -238,7 +238,7 @@ public function testLoadCartNoCartInSession() { * @covers ::updateCart */ public function testUpdateCart() { - $session = $this->getMock('Drupal\acm\SessionStoreInterface'); + $session = $this->createMock('Drupal\acm\SessionStoreInterface'); $session->expects($this->exactly(1)) ->method('get') diff --git a/modules/acm_sku/tests/src/Functional/CategoryManagerTest.php b/modules/acm_sku/tests/src/Functional/CategoryManagerTest.php index 8190ea6..d46187c 100644 --- a/modules/acm_sku/tests/src/Functional/CategoryManagerTest.php +++ b/modules/acm_sku/tests/src/Functional/CategoryManagerTest.php @@ -10,6 +10,12 @@ * @group acm_sku */ class CategoryManagerTest extends BrowserTestBase { + + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + /** * {@inheritdoc} */ diff --git a/modules/acm_sku/tests/src/Functional/ProductManagerTest.php b/modules/acm_sku/tests/src/Functional/ProductManagerTest.php index d6675e1..fd41202 100644 --- a/modules/acm_sku/tests/src/Functional/ProductManagerTest.php +++ b/modules/acm_sku/tests/src/Functional/ProductManagerTest.php @@ -11,6 +11,11 @@ * @group acm_sku */ class ProductManagerTest extends BrowserTestBase { + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + /** * {@inheritdoc} */ diff --git a/modules/acm_sku/tests/src/Functional/StockManagerTest.php b/modules/acm_sku/tests/src/Functional/StockManagerTest.php index 870b2fd..fb40a12 100644 --- a/modules/acm_sku/tests/src/Functional/StockManagerTest.php +++ b/modules/acm_sku/tests/src/Functional/StockManagerTest.php @@ -10,6 +10,12 @@ * @group acm_sku */ class StockManagerTest extends BrowserTestBase { + + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + /** * {@inheritdoc} */ From 24a32dcbf9e087d1af5969b6abd4c29b928f4be7 Mon Sep 17 00:00:00 2001 From: Jakob Perry Date: Fri, 15 May 2020 00:46:05 -0700 Subject: [PATCH 13/14] ACM D9 Compatibility. --- .travis.yml | 1 + modules/acm/acm.module | 5 +- modules/acm/acm.services.yml | 2 +- modules/acm/src/Connector/TestAPIWrapper.php | 2 +- .../src/Controller/CommerceUserController.php | 28 ++++++++--- modules/acm/src/Element/AcmAddress.php | 4 +- .../acm/src/Form/CommerceUserLoginForm.php | 4 +- .../acm/src/Form/CommerceUserPasswordForm.php | 4 +- .../CommerceUserPasswordTokenResetForm.php | 4 +- .../src/Form/CommerceUserRegistrationForm.php | 2 +- .../rest/resource/VerifyMappingResource.php | 1 + modules/acm/src/User/CommerceUserManager.php | 17 +++++-- modules/acm/src/User/CommerceUserSession.php | 2 +- modules/acm_cart/src/Form/EmptyCartForm.php | 2 +- .../tests/src/Unit/CartStorageTest.php | 4 +- .../Plugin/CheckoutFlow/CheckoutFlowBase.php | 19 +++++-- .../rest/resource/CustomerDeleteResource.php | 1 + .../src/RouteExceptionHandler.php | 2 +- .../rest/resource/PromotionSyncResource.php | 1 + modules/acm_sku/acm_sku.install | 49 ++++++------------- modules/acm_sku/acm_sku.module | 3 +- .../acm_sku/src/Controller/SKUController.php | 6 +-- .../rest/resource/CategorySyncResource.php | 1 + .../resource/ProductStockSyncResource.php | 1 + .../rest/resource/ProductSyncResource.php | 1 + .../src/Functional/CategoryManagerTest.php | 2 +- tests/_includes.sh | 13 +++++ tests/install.sh | 25 ++++++++++ 28 files changed, 137 insertions(+), 69 deletions(-) create mode 100644 tests/_includes.sh create mode 100755 tests/install.sh diff --git a/.travis.yml b/.travis.yml index 9da73de..897ff1c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,6 +52,7 @@ before_install: - ../orca/bin/travis/before_install.sh install: ../orca/bin/travis/install.sh + #- ./tests/install.sh before_script: ../orca/bin/travis/before_script.sh diff --git a/modules/acm/acm.module b/modules/acm/acm.module index 6393e09..162a585 100644 --- a/modules/acm/acm.module +++ b/modules/acm/acm.module @@ -10,6 +10,7 @@ use Drupal\acm\User\CommerceAccountInterface; use Drupal\Component\Render\PlainTextOutput; use Drupal\Component\Utility\Crypt; use Drupal\Core\Site\Settings; +use Drupal\Core\Url; /** * For the all. @@ -114,10 +115,10 @@ function acm_mail_tokens(array &$replacements, array $data, array $options) { * they can change their password. */ function acm_commerce_user_pass_reset_url(CommerceAccountInterface $account, array $options = []) { - $timestamp = REQUEST_TIME; + $timestamp = \Drupal::time()->getRequestTime(); $langcode = isset($options['langcode']) ? $options['langcode'] : $account->getPreferredLangcode(); $email = $account->getEmail(); - return \Drupal::url('acm.external_user_password_reset', + return Url::fromRoute('acm.external_user_password_reset', [ 'email' => base64_encode($email), 'timestamp' => $timestamp, diff --git a/modules/acm/acm.services.yml b/modules/acm/acm.services.yml index 8dd0695..0ea373d 100644 --- a/modules/acm/acm.services.yml +++ b/modules/acm/acm.services.yml @@ -72,7 +72,7 @@ services: acm.commerce_user_manager: class: Drupal\acm\User\CommerceUserManager - arguments: ['@cache.commerce_user', '@acm.current_user'] + arguments: ['@cache.commerce_user', '@acm.current_user', '@datetime.time'] acm.route_subscriber: class: Drupal\acm\Routing\CommerceUserRoutes diff --git a/modules/acm/src/Connector/TestAPIWrapper.php b/modules/acm/src/Connector/TestAPIWrapper.php index 2e864b1..1052805 100644 --- a/modules/acm/src/Connector/TestAPIWrapper.php +++ b/modules/acm/src/Connector/TestAPIWrapper.php @@ -218,7 +218,7 @@ private function generateOrder($email = '', $status = 'shipped', $state = 'new') $order['coupon'] = 'GREAT DEAL'; $order['status'] = $status; $order['state'] = $state; - $order['created_at'] = REQUEST_TIME; + $order['created_at'] = \Drupal::time()->getRequestTime(); $order['order_id'] = $this->generateOrderId(); return $order; diff --git a/modules/acm/src/Controller/CommerceUserController.php b/modules/acm/src/Controller/CommerceUserController.php index f7b3b91..b60c5c9 100644 --- a/modules/acm/src/Controller/CommerceUserController.php +++ b/modules/acm/src/Controller/CommerceUserController.php @@ -8,6 +8,7 @@ use Drupal\acm\User\AccountProxyInterface; use Drupal\acm\User\CommerceUserSession; use Drupal\acm_cart\CartStorageInterface; +use Drupal\Component\Datetime\TimeInterface; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Datetime\DateFormatterInterface; use Drupal\user\UserAuthInterface; @@ -27,6 +28,13 @@ class CommerceUserController extends ControllerBase { */ protected $dateFormatter; + /** + * The time service. + * + * @var \Drupal\Component\Datetime\TimeInterface + */ + protected $time; + /** * The session storage. * @@ -67,6 +75,8 @@ class CommerceUserController extends ControllerBase { * * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter * The date formatter service. + * @param \Drupal\Component\Datetime\TimeInterface $time + * The time service. * @param \Drupal\acm\SessionStoreInterface $session * The session. * @param \Drupal\user\UserAuthInterface $user_auth @@ -78,8 +88,9 @@ class CommerceUserController extends ControllerBase { * @param \Drupal\acm_cart\CartStorageInterface $cartStorage * Cart Storage object. */ - public function __construct(DateFormatterInterface $date_formatter, SessionStoreInterface $session, UserAuthInterface $user_auth, AccountProxyInterface $commerce_user_manager, APIWrapperInterface $api_wrapper, CartStorageInterface $cartStorage) { + public function __construct(DateFormatterInterface $date_formatter, TimeInterface $time, SessionStoreInterface $session, UserAuthInterface $user_auth, AccountProxyInterface $commerce_user_manager, APIWrapperInterface $api_wrapper, CartStorageInterface $cartStorage) { $this->dateFormatter = $date_formatter; + $this->time = $time; $this->session = $session; $this->userAuth = $user_auth; $this->commerceUserManager = $commerce_user_manager; @@ -93,6 +104,7 @@ public function __construct(DateFormatterInterface $date_formatter, SessionStore public static function create(ContainerInterface $container) { return new static( $container->get('date.formatter'), + $container->get('datetime.time'), $container->get('acm.session_storage'), $container->get('acm.auth'), $container->get('acm.commerce_user_manager'), @@ -217,15 +229,15 @@ public function resetPassLogin(Request $request, $email, $timestamp, $hash) { $account = new CommerceUserSession($user); // The current user is not logged in, so check the parameters. - $current = REQUEST_TIME; + $current = $this->time->getRequestTime(); // Time out, in seconds, until login URL expires. $timeout = $this->config('user.settings')->get('password_reset_timeout'); if ($current - $timestamp > $timeout) { - drupal_set_message($this->t('you have tried to use a one-time password reset link that has expired. Please request a new one using the form below.'), 'error'); + $this->messenger()->addError('you have tried to use a one-time password reset link that has expired. Please request a new one using the form below.'); return $this->redirect('acm.external_user_password'); } - elseif (($timestamp <= $current) && Crypt::hashEquals($hash, acm_commerce_user_pass_rehash($account, $timestamp))) { + elseif (($timestamp <= $current) && hash_equals($hash, acm_commerce_user_pass_rehash($account, $timestamp))) { $password_values = $request->get('new_password'); $pass1 = trim($password_values['pass1']); $pass2 = trim($password_values['pass2']); @@ -233,7 +245,7 @@ public function resetPassLogin(Request $request, $email, $timestamp, $hash) { if (strcmp($pass1, $pass2)) { // Passwords don't match, return back to the reset password page so // they can correct. - drupal_set_message($this->t('The passwords you entered do not match.'), 'error'); + $this->messenger()->addError('The passwords you entered do not match.'); return $this->redirect( 'acm.external_user_password_reset', [ 'email' => base64_encode($email), @@ -259,16 +271,16 @@ public function resetPassLogin(Request $request, $email, $timestamp, $hash) { } if ($updated_user) { - drupal_set_message($this->t('Your password has been updated.')); + $this->messenger()->addStatus('Your password has been updated.'); return $this->redirect('acm_customer.view_page'); } else { - drupal_set_message($this->t('There was an issue updating your password.'), 'error'); + $this->messenger()->addError('There was an issue updating your password.'); return $this->redirect('acm.external_user_password'); } } - drupal_set_message($this->t('You have tried to use a one-time password reset link that has either been used or is no longer valid. Please request a new one using the form below.'), 'error'); + $this->messenger()->addError('You have tried to use a one-time password reset link that has either been used or is no longer valid. Please request a new one using the form below.'); return $this->redirect('acm.external_user_password'); } diff --git a/modules/acm/src/Element/AcmAddress.php b/modules/acm/src/Element/AcmAddress.php index 45d8ec3..30bb974 100644 --- a/modules/acm/src/Element/AcmAddress.php +++ b/modules/acm/src/Element/AcmAddress.php @@ -357,7 +357,7 @@ public static function validateAddress(&$element, FormStateInterface $form_state // Address is valid and no suggestion came back. if (isset($response['result']['valid']) && empty($response['result']['suggested'])) { - drupal_set_message($address_review_text, 'status'); + \Drupal::messenger()->addStatus($address_review_text); } // Address is in review and there's a suggestion that we use to pre-fill // the address fields. @@ -374,7 +374,7 @@ public static function validateAddress(&$element, FormStateInterface $form_state } } - drupal_set_message($address_review_text, 'status'); + \Drupal::messenger()->addStatus($address_review_text); } // Address failed validation. else { diff --git a/modules/acm/src/Form/CommerceUserLoginForm.php b/modules/acm/src/Form/CommerceUserLoginForm.php index 132cb9c..6660dcc 100644 --- a/modules/acm/src/Form/CommerceUserLoginForm.php +++ b/modules/acm/src/Form/CommerceUserLoginForm.php @@ -145,10 +145,10 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $account = $this->commerceUserManager->getAccount(); if ($account && $account->isAnonymous()) { - drupal_set_message($this->t('There was an issue logging you in, please try again.')); + $this->messenger('There was an issue logging you in, please try again.'); } else { - $this->logger('acm')->notice('Commerce session opened for %name.', ['%name' => $account->getUsername()]); + $this->logger('acm')->notice('Commerce session opened for %name.', ['%name' => $account->getAccountName()]); // Convert the guest cart after login. $customer_id = $account->id(); diff --git a/modules/acm/src/Form/CommerceUserPasswordForm.php b/modules/acm/src/Form/CommerceUserPasswordForm.php index 7ebc9b4..876bd50 100644 --- a/modules/acm/src/Form/CommerceUserPasswordForm.php +++ b/modules/acm/src/Form/CommerceUserPasswordForm.php @@ -122,7 +122,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { if ($ecomm_pass_reset) { $this->apiWrapper->resetCustomerPassword($email); $this->logger('acm')->notice('Password reset triggered for email %email.', ['%email' => $email]); - drupal_set_message($user_message); + $this->messenger->addMessage($user_message); return; } @@ -146,7 +146,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $mail = \Drupal::service('plugin.manager.mail')->mail('acm', 'commerce_user_reset_password', $email, $langcode, $params, $site_mail); if (!empty($mail)) { $this->logger('acm')->notice('Password reset instructions mailed to %email.', ['%email' => $email]); - drupal_set_message($user_message); + $this->messenger->addMessage($user_message); } $form_state->setRedirect('acm.external_user_login'); diff --git a/modules/acm/src/Form/CommerceUserPasswordTokenResetForm.php b/modules/acm/src/Form/CommerceUserPasswordTokenResetForm.php index 1269eb4..6073232 100644 --- a/modules/acm/src/Form/CommerceUserPasswordTokenResetForm.php +++ b/modules/acm/src/Form/CommerceUserPasswordTokenResetForm.php @@ -160,11 +160,11 @@ public function submitForm(array &$form, FormStateInterface $form_state) { } if ($updated_user) { - drupal_set_message($this->t('Your password has been updated.')); + $this->messenger->addStatus('Your password has been updated.'); return $this->redirect('acm_customer.view_page'); } else { - drupal_set_message($this->t('There was an issue updating your password.'), 'error'); + $this->messenger->addError('There was an issue updating your password.'); } } diff --git a/modules/acm/src/Form/CommerceUserRegistrationForm.php b/modules/acm/src/Form/CommerceUserRegistrationForm.php index eb68902..1be71fc 100644 --- a/modules/acm/src/Form/CommerceUserRegistrationForm.php +++ b/modules/acm/src/Form/CommerceUserRegistrationForm.php @@ -210,7 +210,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $account = new CommerceUserSession($customer); $account->setAccessToken($token); $this->currentUser->setAccount($account); - $this->logger('acm')->notice('Commerce session opened for %name.', ['%name' => $account->getUsername()]); + $this->logger('acm')->notice('Commerce session opened for %name.', ['%name' => $account->getAccountName()]); // Convert the guest cart after login. $customer_id = $account->id(); diff --git a/modules/acm/src/Plugin/rest/resource/VerifyMappingResource.php b/modules/acm/src/Plugin/rest/resource/VerifyMappingResource.php index 29fbe4d..c51bead 100644 --- a/modules/acm/src/Plugin/rest/resource/VerifyMappingResource.php +++ b/modules/acm/src/Plugin/rest/resource/VerifyMappingResource.php @@ -1,5 +1,6 @@ cache = $cache; $this->currentCommerceUser = $current_commerce_user; + $this->time = $time; } /** @@ -67,7 +78,7 @@ public function setAccount($account = NULL) { // Store the account for 5 minutes to prevent unnecessary API calls. $access_token = $this->getAccessToken(); - $expire = 600 + \Drupal::time()->getRequestTime(); + $expire = 600 + $this->time->getRequestTime(); $this->cache->set(self::USER_STORAGE_KEY . ':' . $access_token, $account, $expire); } diff --git a/modules/acm/src/User/CommerceUserSession.php b/modules/acm/src/User/CommerceUserSession.php index 00a7624..0b9d4b2 100644 --- a/modules/acm/src/User/CommerceUserSession.php +++ b/modules/acm/src/User/CommerceUserSession.php @@ -188,7 +188,7 @@ public function getDisplayName() { public function getTimeZone() { // Will return the value for system.date.timezone.default since this user // is always anonymous in drupal. - return drupal_get_user_timezone(); + return date_default_timezone_get(); } /** diff --git a/modules/acm_cart/src/Form/EmptyCartForm.php b/modules/acm_cart/src/Form/EmptyCartForm.php index 7f60c19..c965a45 100644 --- a/modules/acm_cart/src/Form/EmptyCartForm.php +++ b/modules/acm_cart/src/Form/EmptyCartForm.php @@ -132,7 +132,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $this->cartStorage->clearCart(); $form_state->setRedirect($route); - drupal_set_message($this->t('Cart has been cleared.')); + $this->messenger()->addMessage('Cart has been cleared.'); } /** diff --git a/modules/acm_cart/tests/src/Unit/CartStorageTest.php b/modules/acm_cart/tests/src/Unit/CartStorageTest.php index bf52177..08a0c82 100644 --- a/modules/acm_cart/tests/src/Unit/CartStorageTest.php +++ b/modules/acm_cart/tests/src/Unit/CartStorageTest.php @@ -91,7 +91,9 @@ protected function setUp() { return $m->getName(); }, (new \ReflectionClass($interface))->getMethods()); $methods[] = 'getCartItemsCount'; - $mock_cart = $this->createMock($interface, $methods); + $mock_cart = $this->getMockBuilder($interface) + ->setMethods($methods) + ->getMock(); $mock_cart->cart = $cart; $mock_cart->expects($this->any()) ->method('id') diff --git a/modules/acm_checkout/src/Plugin/CheckoutFlow/CheckoutFlowBase.php b/modules/acm_checkout/src/Plugin/CheckoutFlow/CheckoutFlowBase.php index 879fdb1..cc9bcd2 100644 --- a/modules/acm_checkout/src/Plugin/CheckoutFlow/CheckoutFlowBase.php +++ b/modules/acm_checkout/src/Plugin/CheckoutFlow/CheckoutFlowBase.php @@ -6,6 +6,7 @@ use Drupal\acm\Response\NeedsRedirectException; use Drupal\acm\User\AccountProxyInterface; use Drupal\acm_cart\CartStorageInterface; +use Drupal\Component\Datetime\TimeInterface; use Drupal\Component\Utility\NestedArray; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Link; @@ -59,6 +60,13 @@ abstract class CheckoutFlowBase extends PluginBase implements CheckoutFlowInterf */ protected $stepId; + /** + * The time service. + * + * @var \Drupal\Component\Datetime\TimeInterface + */ + protected $time; + /** * Constructs a new CheckoutFlowBase object. * @@ -78,8 +86,12 @@ abstract class CheckoutFlowBase extends PluginBase implements CheckoutFlowInterf * The api wrapper. * @param \Drupal\acm\User\AccountProxyInterface $commerce_user_manager * The commerce user manager. + * @param \Drupal\Component\Datetime\TimeInterface $time + * The time service. + * + * @throws \Drupal\acm\Response\NeedsRedirectException */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, EventDispatcherInterface $event_dispatcher, RouteMatchInterface $route_match, CartStorageInterface $cart_storage, APIWrapperInterface $api_wrapper, AccountProxyInterface $commerce_user_manager) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, EventDispatcherInterface $event_dispatcher, RouteMatchInterface $route_match, CartStorageInterface $cart_storage, APIWrapperInterface $api_wrapper, AccountProxyInterface $commerce_user_manager, TimeInterface $time) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->setConfiguration($configuration); @@ -102,7 +114,8 @@ public static function create(ContainerInterface $container, array $configuratio $container->get('current_route_match'), $container->get('acm_cart.cart_storage'), $container->get('acm.api'), - $container->get('acm.commerce_user_manager') + $container->get('acm.commerce_user_manager'), + $container->get('datetime.time') ); } @@ -357,7 +370,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { return; } - $timestamp = \Drupal::time()->getRequestTime(); + $timestamp = $this->time->getRequestTime(); $request = \Drupal::request(); // Store the order time and order id to a cookie so that any checkout diff --git a/modules/acm_customer/src/Plugin/rest/resource/CustomerDeleteResource.php b/modules/acm_customer/src/Plugin/rest/resource/CustomerDeleteResource.php index ccbbfb1..544a6e1 100644 --- a/modules/acm_customer/src/Plugin/rest/resource/CustomerDeleteResource.php +++ b/modules/acm_customer/src/Plugin/rest/resource/CustomerDeleteResource.php @@ -1,5 +1,6 @@ getConfig('message', $e); if (!empty($message) && PHP_SAPI !== 'cli') { - drupal_set_message($message, 'error'); + \Drupal::messenger()->addError($message); } } diff --git a/modules/acm_promotion/src/Plugin/rest/resource/PromotionSyncResource.php b/modules/acm_promotion/src/Plugin/rest/resource/PromotionSyncResource.php index 9395405..32d3105 100644 --- a/modules/acm_promotion/src/Plugin/rest/resource/PromotionSyncResource.php +++ b/modules/acm_promotion/src/Plugin/rest/resource/PromotionSyncResource.php @@ -1,5 +1,6 @@ applyUpdates(); + $definition_update_manager = \Drupal::entityDefinitionUpdateManager(); + if ($old_stock_field = $definition_update_manager->getFieldStorageDefinition('stock', 'acm_sku')) { + $definition_update_manager->uninstallFieldStorageDefinition($old_stock_field); + } } /** @@ -128,43 +132,22 @@ function acm_sku_update_8001() { * "Null value not allowed" */ function acm_sku_update_8101() { - try { - $status_storage_schema = [ - 'acm_sku' => [ - 'fields' => [ - 'status' => [ - 'type' => 'int', - 'size' => 'tiny', - 'not null' => TRUE, - ], - ], - ], - ]; - \Drupal::keyValue('entity.storage_schema.sql') - ->set('acm_sku.field_schema_data.status', $status_storage_schema); - $database = \Drupal::database(); - $table_name = 'acm_sku'; - $column_name = 'status'; - if ($database->schema()->tableExists($table_name) && !$database->schema()->fieldExists($table_name, $column_name)) { - $database->schema()->addField($table_name, $column_name, [ - 'type' => 'int', - 'size' => 'tiny', - 'not null' => TRUE, - 'description' => 'Whether the SKU is available or not.', - 'default' => 1, - ]); - - \Drupal::entityDefinitionUpdateManager()->applyUpdates(); - } - } - catch (\Exception $e) { - \Drupal::logger('acm_sku')->error($e->getMessage()); - } + $storage_definition = BaseFieldDefinition::create('boolean') + ->setLabel(t('Status')) + ->setDescription(t('Whether the SKU is available or not.')) + ->setDefaultValue(TRUE); + + \Drupal::entityDefinitionUpdateManager() + ->installFieldStorageDefinition('status', 'acm_sku', 'acm_sku', $storage_definition); } /** * Change type of attributes field. + * + * We do this because updateFieldStorageDefinition will not allow updates to + * any fields with existing data in it. We must first clear the field of data + * make the change, and then copy the data back. */ function acm_sku_update_8102() { try { diff --git a/modules/acm_sku/acm_sku.module b/modules/acm_sku/acm_sku.module index 4bc1bf9..76a21cc 100644 --- a/modules/acm_sku/acm_sku.module +++ b/modules/acm_sku/acm_sku.module @@ -9,6 +9,7 @@ */ use Drupal\Core\Render\Element; +use Drupal\Core\Url; /** * Implements hook_theme(). @@ -78,7 +79,7 @@ function template_preprocess_sku_add_list(array &$variables) { /** @var \Drupal\acm_sku\Entity\SKUTypeInterface $type */ foreach ($variables['content'] as $type) { $variables['types'][$type->id()]['label'] = $type->label(); - $variables['types'][$type->id()]['url'] = \Drupal::url('acm_sku.sku_add', ['acm_sku_type' => $type->id()]); + $variables['types'][$type->id()]['url'] = Url::fromRoute('acm_sku.sku_add', ['acm_sku_type' => $type->id()]); } } } diff --git a/modules/acm_sku/src/Controller/SKUController.php b/modules/acm_sku/src/Controller/SKUController.php index c541ad4..4e67c3e 100644 --- a/modules/acm_sku/src/Controller/SKUController.php +++ b/modules/acm_sku/src/Controller/SKUController.php @@ -22,7 +22,7 @@ class SKUController extends ControllerBase { * A SKU submission form. */ public function add(SKUTypeInterface $acm_sku_type) { - $sku = $this->entityManager() + $sku = $this->entityTypeManager() ->getStorage('acm_sku') ->create(['type' => $acm_sku_type->id()]); @@ -60,13 +60,13 @@ public function addPage() { $build = [ '#theme' => 'sku_add_list', '#cache' => [ - 'tags' => $this->entityManager()->getDefinition('acm_sku_type')->getListCacheTags(), + 'tags' => $this->entityTypeManager()->getDefinition('acm_sku_type')->getListCacheTags(), ], ]; $content = []; - foreach ($this->entityManager()->getStorage('acm_sku_type')->loadMultiple() as $type) { + foreach ($this->entityTypeManager()->getStorage('acm_sku_type')->loadMultiple() as $type) { $content[$type->id()] = $type; } diff --git a/modules/acm_sku/src/Plugin/rest/resource/CategorySyncResource.php b/modules/acm_sku/src/Plugin/rest/resource/CategorySyncResource.php index 2bfa86b..d43dc20 100644 --- a/modules/acm_sku/src/Plugin/rest/resource/CategorySyncResource.php +++ b/modules/acm_sku/src/Plugin/rest/resource/CategorySyncResource.php @@ -1,5 +1,6 @@ Date: Fri, 15 May 2020 00:57:31 -0700 Subject: [PATCH 14/14] Restore all of travis' testing. --- .travis.yml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 897ff1c..dbb734d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,19 +30,18 @@ jobs: - { name: "Static code analysis", env: ORCA_JOB=STATIC_CODE_ANALYSIS } - { name: "Deprecated code scan", env: ORCA_JOB=DEPRECATED_CODE_SCAN } - { name: "Isolated test w/ recommended package versions", env: ORCA_JOB=ISOLATED_RECOMMENDED } -# - { name: "Integrated test w/ recommended package versions", env: ORCA_JOB=INTEGRATED_RECOMMENDED } -# - { name: "Integrated test w/ recommended package versions & previous minor release of Drupal core", env: ORCA_JOB=CORE_PREVIOUS } -# - { name: "Isolated test w/ dev package versions", env: ORCA_JOB=ISOLATED_DEV } -# - { name: "Integrated test w/ dev package versions", env: ORCA_JOB=INTEGRATED_DEV } -# - { name: "Integrated test w/ dev package versions & next minor dev version of Drupal core", env: ORCA_JOB=CORE_NEXT } + - { name: "Integrated test w/ recommended package versions", env: ORCA_JOB=INTEGRATED_RECOMMENDED } + - { name: "Integrated test w/ recommended package versions & previous minor release of Drupal core", env: ORCA_JOB=CORE_PREVIOUS } + - { name: "Isolated test w/ dev package versions", env: ORCA_JOB=ISOLATED_DEV } + - { name: "Integrated test w/ dev package versions", env: ORCA_JOB=INTEGRATED_DEV } + - { name: "Integrated test w/ dev package versions & next minor dev version of Drupal core", env: ORCA_JOB=CORE_NEXT } - { name: "D9 readiness test", php: "7.3", env: ORCA_JOB=D9_READINESS} allow_failures: # Dev jobs are allowed to fail due to their inherent instability. -# - env: ORCA_JOB=ISOLATED_DEV -# - env: ORCA_JOB=INTEGRATED_DEV -# - env: ORCA_JOB=CORE_NEXT + - env: ORCA_JOB=ISOLATED_DEV + - env: ORCA_JOB=INTEGRATED_DEV + - env: ORCA_JOB=CORE_NEXT # Temporary allowances. - - env: ORCA_JOB=STATIC_CODE_ANALYSIS - env: ORCA_JOB=DEPRECATED_CODE_SCAN # You may need to allow the D9 readiness job to fail in the short term. - { php: "7.3", env: ORCA_JOB=D9_READINESS }