Skip to content

Commit

Permalink
Changes for PHPCS fixes (#502)
Browse files Browse the repository at this point in the history
  • Loading branch information
kedarkhaire authored Oct 1, 2024
1 parent 88860bc commit 28d8f75
Show file tree
Hide file tree
Showing 206 changed files with 459 additions and 547 deletions.
2 changes: 1 addition & 1 deletion apigee_m10n.api.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
* MA 02110-1301, USA.
*/

use Drupal\apigee_m10n\Entity\PurchasedPlanInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\apigee_m10n\Entity\PurchasedPlanInterface;

/**
* @file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

namespace Drupal\apigee_m10n_add_credit;

use Drupal\apigee_m10n_add_credit\Plugin\AddCreditEntityTypeManagerInterface;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\apigee_m10n_add_credit\Plugin\AddCreditEntityTypeManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

namespace Drupal\apigee_m10n_add_credit;

use Drupal\commerce_product\Entity\ProductInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\commerce_product\Entity\ProductInterface;

/**
* Defines a service for managing add credit products.
Expand Down
24 changes: 12 additions & 12 deletions modules/apigee_m10n_add_credit/src/AddCreditService.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,6 @@

namespace Drupal\apigee_m10n_add_credit;

use Drupal\apigee_m10n\Entity\Form\PurchasedPlanForm;
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;
use Drupal\commerce_checkout\Plugin\Commerce\CheckoutFlow\CheckoutFlowBase;
use Drupal\commerce_order\Entity\OrderItemInterface;
use Drupal\commerce_product\Entity\ProductType;
use Drupal\commerce_product\Entity\ProductVariationInterface;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Cache\Cache;
Expand All @@ -44,6 +34,16 @@
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Url;
use Drupal\apigee_m10n\Entity\Form\PurchasedPlanForm;
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;
use Drupal\commerce_checkout\Plugin\Commerce\CheckoutFlow\CheckoutFlowBase;
use Drupal\commerce_order\Entity\OrderItemInterface;
use Drupal\commerce_product\Entity\ProductType;
use Drupal\commerce_product\Entity\ProductVariationInterface;

/**
* Helper service to handle basic module tasks.
Expand Down Expand Up @@ -403,7 +403,7 @@ public function apigeeM10nPrepaidBalanceListAlter(array &$build, EntityInterface
}
}

// TODO: This can be move to entity operations when/if prepaid balance are
// @todo This can be move to entity operations when/if prepaid balance are
// made into entities.
if ((count($build['table']['#rows']))) {
$has_operations = FALSE;
Expand Down Expand Up @@ -593,7 +593,7 @@ public static function checkoutFormReviewValidate(array $form, FormStateInterfac
foreach ($add_credit_items as $add_credit_item) {
$price = $add_credit_item->getTotalPrice();
$currency_code = strtolower($price->getCurrencyCode());
// TODO: Fail validation if the currency does not exist.
// @todo Fail validation if the currency does not exist.
if (isset($supported_currencies[$currency_code])
&& ($supported_currency = $supported_currencies[$currency_code])
&& ($minimum_top_up_amount = $supported_currency->getMinimumTopUpAmount())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@

namespace Drupal\apigee_m10n_add_credit;

use Drupal\apigee_m10n\Entity\PurchasedPlanInterface;
use Drupal\apigee_m10n\Entity\PurchasedProductInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\apigee_m10n\Entity\PurchasedPlanInterface;
use Drupal\apigee_m10n\Entity\PurchasedProductInterface;

/**
* The interface for the add credit service..
Expand Down
6 changes: 3 additions & 3 deletions modules/apigee_m10n_add_credit/src/Element/PriceRange.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ public static function processElement(array $element, FormStateInterface $form_s
],
'#attached' => [
'library' => [
'apigee_m10n_add_credit/price_range'
'apigee_m10n_add_credit/price_range',
],
],
'fields' => [
'#type' => 'container',
]
],
];

// Add the help text if specified.
Expand Down Expand Up @@ -153,7 +153,7 @@ public static function processElement(array $element, FormStateInterface $form_s
$element['price_range']['fields']['minimum']['#required'] = TRUE;

if (isset($element['#ajax'])) {
// TODO: Explain why we have are copying ajax over to number fields.
// @todo Explain why we have are copying ajax over to number fields.
$element['price_range']['fields'][$name]['#ajax'] = $element['#ajax'];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
namespace Drupal\apigee_m10n_add_credit\Entity;

use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityChangedInterface;
use Drupal\Core\Entity\EntityPublishedInterface;
use Drupal\user\EntityOwnerInterface;

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

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\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\apigee_m10n\MonetizationInterface;
use Drupal\apigee_m10n_add_credit\AddCreditConfig;
use Drupal\commerce_price\Price;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
Expand Down Expand Up @@ -162,8 +160,8 @@ public function onCurrencyDelete(ConfigCrudEvent $event) {
$original_data = $config->getOriginal();
$currencyCode = $original_data['currencyCode'];
$addCreditProducts = $this->entityTypeManager->getStorage('commerce_product')->loadByProperties([
'apigee_add_credit_enabled' => '1'
]
'apigee_add_credit_enabled' => '1',
]
);
foreach ($addCreditProducts as $product) {
if ($product_variation = $product->getDefaultVariation()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@

namespace Drupal\apigee_m10n_add_credit\Form;

use Drupal\Core\Form\FormStateInterface;
use Drupal\apigee_m10n_add_credit\AddCreditConfig;
use Drupal\apigee_m10n_add_credit\Plugin\AddCreditEntityTypeManagerInterface;
use Drupal\commerce_cart\Form\AddToCartForm;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Session\AccountInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RequestStack;

/**
* Class AddCreditAddToCartForm.
Expand Down
10 changes: 5 additions & 5 deletions modules/apigee_m10n_add_credit/src/Form/AddCreditConfigForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@

namespace Drupal\apigee_m10n_add_credit\Form;

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 Drupal\apigee_m10n\MonetizationInterface;
use Drupal\apigee_m10n_add_credit\AddCreditConfig;
use Drupal\commerce_price\Entity\Currency;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
Expand Down Expand Up @@ -120,8 +120,8 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'#type' => 'container',
'#attributes' => [
'class' => [
'container-inline'
]
'container-inline',
],
],
'text' => [
'#type' => 'html_tag',
Expand Down
13 changes: 5 additions & 8 deletions modules/apigee_m10n_add_credit/src/Form/BillingTypeForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,14 @@

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 Drupal\Core\Logger\LoggerChannelFactory;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\apigee_m10n\MonetizationInterface;
use Drupal\user\UserInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

Expand Down Expand Up @@ -146,7 +143,7 @@ public function getFormId() {
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, UserInterface $user = NULL) {
public function buildForm(array $form, FormStateInterface $form_state, ?UserInterface $user = NULL) {
$billingType = ['postpaid' => 'Postpaid' , 'prepaid' => 'Prepaid'];
$developer_billingtype = $this->monetization->getBillingtype($user);
$form['billingtype'] = [
Expand All @@ -168,16 +165,16 @@ public function buildForm(array $form, FormStateInterface $form_state, UserInter
'#states' => [
'disabled' => [
':input[name="billingtype"]' => ['value' => strtolower($developer_billingtype)],
]
]
],
],
];
return $form;
}

/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state, UserInterface $user = NULL) {
public function submitForm(array &$form, FormStateInterface $form_state, ?UserInterface $user = NULL) {
$user = $this->routeMatch->getParameter('user');
$billingtype_selected = $form_state->getValue('billingtype');
$form_state->setRedirect('apigee_m10n_add_credit.userbillingtype.confirm', ['user' => $user->id(), 'billingtype' => $billingtype_selected]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@

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\Core\Access\AccessResult;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Drupal\apigee_m10n\MonetizationInterface;
use Drupal\user\Entity\User;
use Symfony\Component\DependencyInjection\ContainerInterface;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

namespace Drupal\apigee_m10n_add_credit\Form;

use Drupal\apigee_m10n\MonetizationInterface;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\apigee_m10n\MonetizationInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
Expand Down
17 changes: 8 additions & 9 deletions modules/apigee_m10n_add_credit/src/Job/BalanceAdjustmentJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@

use Apigee\Edge\Api\Management\Entity\CompanyInterface;
use Apigee\Edge\Api\Monetization\Controller\PrepaidBalanceControllerInterface;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Language\Language;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\apigee_edge\Entity\DeveloperInterface;
use Drupal\apigee_edge\Job\EdgeJob;
use Drupal\apigee_m10n\Controller\PrepaidBalanceController;
use Drupal\apigee_m10n_add_credit\AddCreditConfig;
use Drupal\commerce_order\Adjustment;
use Drupal\commerce_order\Entity\OrderInterface;
use Drupal\commerce_price\Price;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Language\Language;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\user\UserInterface;

/**
Expand All @@ -44,7 +44,7 @@
* error will let the job runner know that the request was unsuccessful and will
* trigger a retry.
*
* @todo: Handle refunds when the monetization API supports it.
* @todo Handle refunds when the monetization API supports it.
*/
class BalanceAdjustmentJob extends EdgeJob {

Expand Down Expand Up @@ -100,7 +100,7 @@ class BalanceAdjustmentJob extends EdgeJob {
* @param \Drupal\commerce_order\Entity\OrderInterface $order
* The drupal commerce order.
*/
public function __construct(EntityInterface $company_or_user, Adjustment $adjustment, OrderInterface $order = NULL) {
public function __construct(EntityInterface $company_or_user, Adjustment $adjustment, ?OrderInterface $order = NULL) {
parent::__construct();

// Either a developer or a company can be passed.
Expand Down Expand Up @@ -236,7 +236,6 @@ public function shouldRetry(\Exception $exception): bool {
// wasn't applied, we could return true here and the top-up would be
// retried.
// @todo Return true once we can determine the payment wasn't applied.

return FALSE;
}

Expand Down Expand Up @@ -427,10 +426,10 @@ protected function logTransaction($currency_code, \DateTimeImmutable $transactio
$csv = array_map('str_getcsv', explode("\r\n", $report));

// This assumes the last transaction is the one we just performed.
// @todo: Find a better way to retrieve the transaction ID.
// @todo Find a better way to retrieve the transaction ID.
$transaction = end($csv);

/* @var \Drupal\apigee_m10n_add_credit\Entity\AddCreditLogInterface $log */
/** @var \Drupal\apigee_m10n_add_credit\Entity\AddCreditLogInterface $log */
$log = \Drupal::entityTypeManager()->getStorage('add_credit_log')->create([
'commerce_order' => $this->order ? $this->order->id() : NULL,
'apigee_transaction' => isset($transaction[6]) ?: NULL,
Expand Down
15 changes: 5 additions & 10 deletions modules/apigee_m10n_add_credit/src/Job/BalanceAdjustmentJobX.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,14 @@
namespace Drupal\apigee_m10n_add_credit\Job;

use Apigee\Edge\Api\ApigeeX\Controller\PrepaidBalanceControllerInterface;
use Drupal\apigee_edge\Entity\DeveloperInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Language\Language;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\apigee_edge\Job\EdgeJob;
use Drupal\apigee_m10n\Controller\PrepaidBalanceXController;
use Drupal\apigee_m10n_add_credit\AddCreditConfig;
use Drupal\commerce_order\Adjustment;
use Drupal\commerce_order\Entity\OrderInterface;
use Drupal\commerce_price\Price;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Language\Language;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\user\UserInterface;

/**
* An apigee job that will apply a balance adjustment.
Expand All @@ -43,7 +39,7 @@
* error will let the job runner know that the request was unsuccessful and will
* trigger a retry.
*
* @todo: Handle refunds when the monetization API supports it.
* @todo Handle refunds when the monetization API supports it.
*/
class BalanceAdjustmentJobX extends EdgeJob {

Expand Down Expand Up @@ -92,7 +88,7 @@ class BalanceAdjustmentJobX extends EdgeJob {
* @param \Drupal\commerce_order\Entity\OrderInterface $order
* The drupal commerce order.
*/
public function __construct(EntityInterface $developer, Adjustment $adjustment, OrderInterface $order = NULL) {
public function __construct(EntityInterface $developer, Adjustment $adjustment, ?OrderInterface $order = NULL) {
parent::__construct();

$this->developer = $developer->getOwner();
Expand Down Expand Up @@ -220,7 +216,6 @@ public function shouldRetry(\Exception $exception): bool {
// wasn't applied, we could return true here and the top-up would be
// retried.
// @todo Return true once we can determine the payment wasn't applied.

return FALSE;
}

Expand Down
Loading

0 comments on commit 28d8f75

Please sign in to comment.