Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drupal 10 compatibility #436

Merged
merged 9 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:
fail-fast: false
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
drupal-core:
Expand All @@ -42,9 +41,19 @@ jobs:
instance-type:
- "Edge"
- "X"
#include:
# - php-version: "8.1"
# drupal-core: "10.0.x"
include:
- php-version: "8.1"
drupal-core: "10.0.x"
instance-type: "Edge"
- php-version: "8.1"
drupal-core: "10.0.x"
instance-type: "X"
- php-version: "8.1"
drupal-core: "10.1.x"
instance-type: "Edge"
- php-version: "8.1"
drupal-core: "10.1.x"
instance-type: "X"

steps:

Expand Down Expand Up @@ -99,8 +108,6 @@ jobs:
composer config --no-plugins allow-plugins.php-http/discovery true
composer config preferred-install."drupal/apigee_edge" source
composer config preferred-install."apigee/apigee-client-php" source
composer require drupal/rules:3.0.0-alpha7
composer require --dev drush/drush
composer config minimum-stability dev
composer require drupal/commerce:^2.16
composer require drupal/token:~1.0
Expand Down
4 changes: 2 additions & 2 deletions apigee_m10n.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ description: Apigee Edge Monetization Drupal integration
package: Apigee

type: module
core_version_requirement: ^8.7.7 || ^9
core_version_requirement: ^9 || ^10

dependencies:
- apigee_edge:apigee_edge
- drupal:link
- requirement:requirement

php: "7.1"
php: 8.0
20 changes: 10 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
"type": "drupal-module",
"description": "Apigee Edge Monetization for Drupal",
"require": {
"php": "^7.4 || ^8.0",
"php": "~8.0 || ~8.1",
"ext-bcmath": "*",
"cweagans/composer-patches": "~1.6",
"commerceguys/intl": "~1.0",
"drupal/apigee_edge": "^2.0.2",
"drupal/core": "^9.4",
"drupal/requirement": "~1.0",
"apigee/apigee-client-php": "^2.0.16"
"commerceguys/intl": "~1.0 || ^2.0",
"drupal/apigee_edge": "^2.0.2 || ^3.0.0",
"drupal/core": "^9.4 || ^10.0",
"drupal/requirement": "^1.2",
"drupal/jquery_ui_dialog": "^2.0",
"apigee/apigee-client-php": "^2.0.16 || ^3.0.0"
},
"require-dev": {
"apigee/apigee-mock-client-php": "^1.1.1",
"behat/mink-extension": "^2.0",
"bex/behat-screenshot": "^1.2",
"drupal/core-dev": "^9.4",
"drush/drush": "^9.0 || ^10.0",
"drupal/drupal-extension": "^4.2.1 || ~5",
"drupal/core-dev": "^9.4 || ^10.0",
"drush/drush": "^11.5",
"mglaman/drupal-check": "^1.3",
"phpmd/phpmd": "^2.8.2",
"phpmetrics/phpmetrics": "^2.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ content:
date_format: medium
custom_date_format: ''
timezone: ''
tooltip:
date_format: long
custom_date_format: ''
time_diff:
enabled: false
future_format: '@interval hence'
past_format: '@interval ago'
granularity: 2
refresh: 60
third_party_settings: { }
ratePlan:
type: entity_reference_label
Expand All @@ -42,6 +51,15 @@ content:
date_format: medium
custom_date_format: ''
timezone: ''
tooltip:
date_format: long
custom_date_format: ''
time_diff:
enabled: false
future_format: '@interval hence'
past_format: '@interval ago'
granularity: 2
refresh: 60
third_party_settings: { }
hidden:
created: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ content:
date_format: custom
custom_date_format: m/d/Y
timezone: ''
tooltip:
date_format: long
custom_date_format: ''
time_diff:
enabled: false
future_format: '@interval hence'
past_format: '@interval ago'
granularity: 2
refresh: 60
text: 'This plan has a new version effective @date. Toggle below to see the future rate plan.'
third_party_settings: { }
products:
Expand Down
58 changes: 58 additions & 0 deletions config/schema/apigee_m10n.schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,35 @@ field.formatter.settings.apigee_datestamp:
timezone:
type: string
label: 'Timezone'
tooltip:
type: mapping
label: Tooltip
mapping:
date_format:
type: string
label: 'Tooltip date format'
custom_date_format:
type: string
label: 'Tooltip custom date format'
time_diff:
type: mapping
label: 'Time difference'
mapping:
enabled:
type: boolean
label: 'Show as time difference'
future_format:
type: string
label: 'Future format'
past_format:
type: string
label: 'Past format'
granularity:
type: integer
label: 'Time units'
refresh:
type: integer
label: 'Refresh interval in seconds'

field.formatter.settings.apigee_tnc_default:
type: mapping
Expand All @@ -112,6 +141,35 @@ field.formatter.settings.apigee_date_and_text_formatter:
timezone:
type: string
label: 'Timezone'
tooltip:
type: mapping
label: Tooltip
mapping:
date_format:
type: string
label: 'Tooltip date format'
custom_date_format:
type: string
label: 'Tooltip custom date format'
time_diff:
type: mapping
label: 'Time difference'
mapping:
enabled:
type: boolean
label: 'Show as time difference'
future_format:
type: string
label: 'Future format'
past_format:
type: string
label: 'Past format'
granularity:
type: integer
label: 'Time units'
refresh:
type: integer
label: 'Refresh interval in seconds'
text:
type: string
label: 'Text'
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Provides the ability to create a Drupal Commerce "Add Credit" produ
package: Apigee

type: module
core_version_requirement: ^8.7.7 || ^9
core_version_requirement: ^9 || ^10

dependencies:
- apigee_m10n:apigee_m10n
Expand All @@ -14,5 +14,6 @@ dependencies:
- commerce:commerce_order
- commerce:commerce_cart
- commerce:commerce_checkout
- jquery_ui_dialog:jquery_ui_dialog

php: "7.1"
php: 8.0
16 changes: 16 additions & 0 deletions modules/apigee_m10n_add_credit/apigee_m10n_add_credit.install
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,19 @@ function apigee_m10n_add_credit_install() {
user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, AddCreditServiceInterface::DEFAULT_AUTHENTICATED_PERMISSIONS);
}
}

/**
* Install jquery_ui_dialog module if apigee_m10n_add_credit module is installed.
*/
function apigee_m10n_add_credit_update_9000(&$sandbox) {
// When upgrading, jquery_ui_dialog module is not enabled.
// Check if apigee_m10n_add_credit module is enabled.
if (Drupal::moduleHandler()->moduleExists('apigee_m10n_add_credit')) {
$installer = \Drupal::service('module_installer');
// Install jquery_ui_dialog module.
$installer->install(['jquery_ui_dialog']);
}

// Clear all caches.
drupal_flush_all_caches();
}
4 changes: 2 additions & 2 deletions modules/apigee_m10n_add_credit/apigee_m10n_add_credit.module
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ function apigee_m10n_add_credit_field_info_alter(&$info) {
}

/**
* Implements hook_field_widget_form_alter().
* Implements hook_field_widget_single_element_form_alter().
*/
function apigee_m10n_add_credit_field_widget_form_alter(&$element, FormStateInterface $form_state, $context) {
function apigee_m10n_add_credit_field_widget_single_element_form_alter(&$element, FormStateInterface $form_state, $context) {
\Drupal::service('apigee_m10n.add_credit')->fieldWidgetFormAlter($element, $form_state, $context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
attach: function attach(context) {
var self = this;
$(".two_decimal_price div input").keyup(function(){
var number = ($(this).val().split('.'));
if (number[1].length > 2)
var number = ($(this).val().split('.'));
// Check if there is value after decimal.
if (number[1] && number[1].length > 2)
{
var price = parseFloat($(this).val());
$(this).val(price.toFixed(2));
Expand Down
4 changes: 2 additions & 2 deletions modules/apigee_m10n_add_credit/src/AddCreditService.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
namespace Drupal\apigee_m10n_add_credit;

use Drupal\apigee_m10n\Entity\Form\PurchasedPlanForm;
use Drupal\apigee_m10n\Entity\PurchasedPlanInterface;
use Drupal\apigee_m10n\Entity\Form\PurchasedProductForm;
use Drupal\apigee_m10n\Entity\PurchasedPlanInterface;
use Drupal\apigee_m10n\Entity\PurchasedProductInterface;
use Drupal\apigee_m10n_add_credit\Form\AddCreditAddToCartForm;
use Drupal\apigee_m10n_add_credit\Plugin\AddCreditEntityTypeManagerInterface;
Expand Down Expand Up @@ -471,7 +471,7 @@ public function apigeeM10nPrepaidBalanceListAlter(array &$build, EntityInterface
$build['table']['#attached'] = [
'library' => [
'core/drupal.dialog.ajax',
'core/jquery.ui.dialog',
'jquery_ui_dialog/dialog',
],
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function inlineEntityFormTableFieldsAlter(&$fields, $context);
public function fieldInfoAlter(&$info);

/**
* Handles `hook_field_widget_form_alter` for the `apigee_m10n_add_credit` module.
* Handles `hook_field_widget_single_element_form_alter` for the `apigee_m10n_add_credit` module.
*
* @param array $element
* The field widget form element as constructed by
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

namespace Drupal\apigee_m10n_add_credit\Entity\Access;

use Drupal\Core\Access\AccessResult;
use Drupal\Core\Entity\EntityAccessControlHandler;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Access\AccessResult;

/**
* Access controller for the Add Credit Log entity.
Expand Down
4 changes: 2 additions & 2 deletions modules/apigee_m10n_add_credit/src/Entity/AddCreditLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

namespace Drupal\apigee_m10n_add_credit\Entity;

use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\user\UserInterface;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@

namespace Drupal\apigee_m10n_add_credit\EventSubscriber;

use Drupal\apigee_m10n\MonetizationInterface;
use Drupal\apigee_m10n_add_credit\AddCreditConfig;
use Drupal\commerce_price\Price;
use Drupal\Core\Config\ConfigCrudEvent;
use Drupal\Core\Config\ConfigEvents;
use Drupal\apigee_m10n_add_credit\AddCreditConfig;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\commerce_price\Price;
use Drupal\apigee_m10n\MonetizationInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
* Class CommerceCurrencyConfigSubscriber.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@

use Drupal\apigee_m10n\MonetizationInterface;
use Drupal\apigee_m10n_add_credit\AddCreditConfig;
use Drupal\commerce_price\Entity\Currency;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\commerce_price\Entity\Currency;

/**
* Class AddCreditConfigForm.
Expand Down
14 changes: 7 additions & 7 deletions modules/apigee_m10n_add_credit/src/Form/BillingTypeForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@
namespace Drupal\apigee_m10n_add_credit\Form;

use Apigee\Edge\Api\ApigeeX\Controller\DeveloperBillingTypeController;
use Drupal\apigee_edge\Entity\Developer;
use Drupal\apigee_m10n\MonetizationInterface;
use Drupal\apigee_m10n_add_credit\Form\GeneralSettingsConfigForm;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Logger\LoggerChannelFactory;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\user\UserInterface;
use Drupal\apigee_edge\Entity\Developer;
use Drupal\Core\Logger\LoggerChannelFactory;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Session\AccountInterface;
use Drupal\apigee_m10n\MonetizationInterface;
use Drupal\apigee_m10n_add_credit\Form\GeneralSettingsConfigForm;
use Drupal\user\UserInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Provides a form to edit developer profile information.
Expand Down
Loading