For the benefit of others, once resolved you also now need to update:
src/PostageServices/ServiceDefinitions/ServiceDestinations.php
2
3 namespace Drupal\commerce_auspost\PostageServices\ServiceDefinitions;
4
5 - use CommerceGuys\Enum\AbstractEnum;
6 -
5 /**
6 * Defines service destinations.
7 *
8 * @package Drupal\commerce_auspost\PostageServices\ServiceDefinitions
9 */
10 - final class ServiceDestinations extends AbstractEnum {
10 + final class ServiceDestinations {
18 + /**
19 + * Returns all available destinations.
20 + *
21 + * @return array
22 + * Array of destination constants.
23 + */
24 + public static function getAll() {
25 + return [
26 + self::DOMESTIC,
27 + self::INTERNATIONAL,
28 + ];
29 + }
30 +
31 + /**
32 + * Asserts that a destination exists.
33 + *
34 + * @param string $destination
35 + * The destination to validate.
36 + *
37 + * @throws \InvalidArgumentException
38 + * If the destination doesn't exist.
39 + */
40 + public static function assertExists($destination) {
41 + if (!in_array($destination, self::getAll(), TRUE)) {
42 + throw new \InvalidArgumentException(sprintf('Invalid destination: %s', $destination));
43 + }
44 + }
45 +
Then in ServiceCodes.php, remove the dependency and appending:
/**
* Returns all available service codes.
*
* @return array
* Array of service code constants.
*/
public static function getAll() {
return [
self::AUS_LETTER_REGULAR_SMALL,
self::AUS_LETTER_REGULAR_LARGE,
self::AUS_LETTER_PRIORITY_SMALL,
self::AUS_LETTER_PRIORITY_LARGE_500,
self::AUS_LETTER_EXPRESS_SMALL,
self::AUS_LETTER_EXPRESS_MEDIUM,
self::AUS_LETTER_EXPRESS_LARGE,
self::AUS_PARCEL_REGULAR,
self::AUS_PARCEL_REGULAR_SATCHEL_500G,
self::AUS_PARCEL_REGULAR_SATCHEL_3KG,
self::AUS_PARCEL_REGULAR_SATCHEL_5KG,
self::AUS_PARCEL_EXPRESS,
self::AUS_PARCEL_EXPRESS_SATCHEL_500G,
self::AUS_PARCEL_EXPRESS_SATCHEL_3KG,
self::AUS_PARCEL_EXPRESS_SATCHEL_5KG,
self::AUS_PARCEL_COURIER,
self::AUS_PARCEL_COURIER_SATCHEL_MEDIUM,
self::INT_LETTER_AIR_OWN_PACKAGING_LIGHT,
self::INT_LETTER_AIR_OWN_PACKAGING_MEDIUM,
self::INT_LETTER_AIR_OWN_PACKAGING_HEAVY,
self::INT_LETTER_COR_OWN_PACKAGING,
self::INT_LETTER_EXP_OWN_PACKAGING,
self::INT_LETTER_REG_SMALL_ENVELOPE,
self::INT_LETTER_REG_LARGE_ENVELOPE,
self::INT_PARCEL_SEA_OWN_PACKAGING,
self::INT_PARCEL_COR_OWN_PACKAGING,
self::INT_PARCEL_STD_OWN_PACKAGING,
self::INT_PARCEL_EXP_OWN_PACKAGING,
self::INT_PARCEL_AIR_OWN_PACKAGING,
];
}
/**
* Asserts that a service code exists.
*
* @param string $code
* The service code to validate.
*
* @throws \InvalidArgumentException
* If the service code doesn't exist.
*/
public static function assertExists($code) {
if (!in_array($code, self::getAll(), TRUE)) {
throw new \InvalidArgumentException(sprintf('Invalid service code: %s', $code));
}
}
Then ServiceOptions.php same thing, adding:
/**
* Returns all available service options.
*
* @return array
* Array of service option constants.
*/
public static function getAll() {
return [
self::AUS_SERVICE_OPTION_STANDARD,
self::AUS_SERVICE_OPTION_EXTRA_COVER,
self::AUS_SERVICE_OPTION_SIGNATURE_ON_DELIVERY,
self::AUS_SERVICE_OPTION_DELIVERY_CONFIRMATION,
self::AUS_SERVICE_OPTION_REGISTERED_POST,
self::AUS_SERVICE_OPTION_PERSON_TO_PERSON,
self::AUS_SERVICE_OPTION_COD_POSTAGE_FEES,
self::AUS_SERVICE_OPTION_COD_MONEY_COLLECTION,
self::INT_TRACKING,
self::INT_EXTRA_COVER,
self::INT_SMS_TRACK_ADVICE,
self::INT_SIGNATURE_ON_DELIVERY,
];
}
/**
* Asserts that a service option exists.
*
* @param string $option
* The service option to validate.
*
* @throws \InvalidArgumentException
* If the service option doesn't exist.
*/
public static function assertExists($option) {
if (!in_array($option, self::getAll(), TRUE)) {
throw new \InvalidArgumentException(sprintf('Invalid service option: %s', $option));
}
}
ServiceTypes.php same thing:
/**
* Returns all available service types.
*
* @return array
* Array of service type constants.
*/
public static function getAll() {
return [
self::PARCEL,
self::LETTER,
];
}
/**
* Asserts that a service type exists.
*
* @param string $type
* The service type to validate.
*
* @throws \InvalidArgumentException
* If the service type doesn't exist.
*/
public static function assertExists($type) {
if (!in_array($type, self::getAll(), TRUE)) {
throw new \InvalidArgumentException(sprintf('Invalid service type: %s', $type));
}
}
The commerceguys/enum library was deprecated because simple constants with static methods are cleaner and don't require an external dependency for basic enum functionality.
When enabling the shipping type there's also a form validation error to do with insurance percentage field due to min="0.1".
src/Forms/ConfigureForm.php with 1 addition and 1 removal
172 '#type' => 'number',
173 '#title' => $this->t('Percentage of order value'),
174 '#description' => $this->t('Percentage of order to add on as insurance. For example, enter 1.5 to add 150% extra insurance cover.'),
175 - '#min' => 0.1,
175 + '#min' => 0,
Also necessary to add "dvdoug/boxpacker": "^3" to the module's composer.json
Various other fixes:
src/Packer/ShipmentPacking/PackableCommercePackageType.php with 1 addition and 1 removal
87 /**
88 * {@inheritdoc}
89 */
90 - public function getReference() {
90 + public function getReference(): string {
src/Plugin/Deriver/ServiceDefinitionDeriver.php with 1 addition and 1 removal
30 'service_type' => $service['type'],
31 'service_code' => $service['service_code'],
32 'option_code' => $service['option_code'],
33 - 'sub_option_code' => $service['sub_option_code'],
33 + 'sub_option_code' => $service['sub_option_code'] ?? '',
BoxPacker interface now requires return type declarations, so the following files need to be updated:
src/Packer/ShipmentPacking/PackableCommercePackageType.php
src/Packer/ShipmentPacking/PackableCommerceOrderItem.php
like this: public function getOuterWidth(): int {
Next issue you'll face is fontis/auspost-api-php dev-master is outdated, relies on php 7. So we'll rewrite to use the cognito/auspost library instead which works with php 8. There's a lot of changes and this comment is already long enough.
I have a patch made already that I have applied, but what needs to be investigated is whether this would break some other functionality.
--- a/src/Plugin/Field/FieldFormatter/ParagraphsTableFormatter.php
+++ b/src/Plugin/Field/FieldFormatter/ParagraphsTableFormatter.php
@@ -458,6 +458,11 @@ class ParagraphsTableFormatter extends EntityReferenceFormatterBase {
foreach ($handler["target_bundles"] as $targetBundle) {
+ // Skip rendering table if no entities exist and AJAX is not enabled
+ if (empty($entities) && empty($setting['ajax'])) {
+ continue;
+ }
+
$table = $table_header = $fields = [];
$table_rows = $notEmptyColumn = [];
if ($setting['number_column']) {
@@ -658,6 +663,12 @@ class ParagraphsTableFormatter extends EntityReferenceFormatterBase {
}
$addButton = NULL;
+
+ // Don't show add button if no entities exist and no table was rendered
+ if (empty($entities) && empty($setting['ajax']) && empty($output)) {
+ return $output;
+ }
+
$userRoles = $this->currentUser->getRoles();
$cardinality = $field_definition->getFieldStorageDefinition()->get('cardinality');
if ($entityId &&
Also encountered this issue. #13 did work in principle, however my database tables are suffixed with "drai_" so "menu_tree" in c9787bdf failed to remove the offending occurrences, until I changed to "drai_menu_tree". Unfortunately I have no idea why my tables are suffixed, whether this is something specific to my installation.