diff --git a/payment/uc_payment/lib/Drupal/uc_payment/Plugin/Ubercart/CheckoutPane/PaymentMethodPane.php b/payment/uc_payment/lib/Drupal/uc_payment/Plugin/Ubercart/CheckoutPane/PaymentMethodPane.php index 9a8a54f..2058f70 100644 --- a/payment/uc_payment/lib/Drupal/uc_payment/Plugin/Ubercart/CheckoutPane/PaymentMethodPane.php +++ b/payment/uc_payment/lib/Drupal/uc_payment/Plugin/Ubercart/CheckoutPane/PaymentMethodPane.php @@ -8,8 +8,11 @@ namespace Drupal\uc_payment\Plugin\Ubercart\CheckoutPane; use Drupal\Component\Plugin\Exception\PluginException; +use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\uc_cart\CheckoutPanePluginBase; use Drupal\uc_order\UcOrderInterface; +use Drupal\uc_payment\Plugin\PaymentMethodManager; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Allows the user to select a payment method and preview the line items. @@ -21,7 +24,43 @@ use Drupal\uc_order\UcOrderInterface; * weight = 6 * ) */ -class PaymentMethodPane extends CheckoutPanePluginBase { +class PaymentMethodPane extends CheckoutPanePluginBase implements ContainerFactoryPluginInterface { + + /** + * The payment method manager. + * + * @var \Drupal\uc_payment\Plugin\PaymentMethodManager + */ + protected $paymentMethodManager; + + /** + * Constructs a PaymentMethodPane object. + * + * @param array $configuration + * A configuration array containing information about the plugin instance. + * @param string $plugin_id + * The plugin ID for the plugin instance. + * @param array $plugin_definition + * The plugin implementation definition. + * @param \Drupal\Core\Utility\Token $token + * The token service. + * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager + * The entity manager. + */ + public function __construct(array $configuration, $plugin_id, array $plugin_definition, PaymentMethodManager $payment_method_manager) { + parent::__construct($configuration, $plugin_id, $plugin_definition); + + $this->paymentMethodManager = $payment_method_manager; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, array $plugin_definition) { + return new static($configuration, $plugin_id, $plugin_definition, + $container->get('plugin.manager.uc_payment.method') + ); + } /** * {@inheritdoc} @@ -95,7 +134,7 @@ class PaymentMethodPane extends CheckoutPanePluginBase { ); try { - $details = \Drupal::service('plugin.manager.uc_payment.method')->createFromOrder($order)->cartDetails($order, $form, $form_state); + $details = $this->paymentMethodManager->createFromOrder($order)->cartDetails($order, $form, $form_state); if ($details) { unset($contents['details']['#markup']); $contents['details'] += $details; @@ -116,7 +155,7 @@ class PaymentMethodPane extends CheckoutPanePluginBase { return FALSE; } $order->setPaymentMethodId($form_state['values']['panes']['payment']['payment_method']); - $result = \Drupal::service('plugin.manager.uc_payment.method')->createFromOrder($order)->cartProcess($order, $form, $form_state); + $result = $this->paymentMethodManager->createFromOrder($order)->cartProcess($order, $form, $form_state); return $result !== FALSE; } @@ -128,7 +167,7 @@ class PaymentMethodPane extends CheckoutPanePluginBase { foreach ($line_items as $line_item) { $review[] = array('title' => $line_item['title'], 'data' => theme('uc_price', array('price' => $line_item['amount']))); } - $method = \Drupal::service('plugin.manager.uc_payment.method')->createFromOrder($order); + $method = $this->paymentMethodManager->createFromOrder($order); $review[] = array('border' => 'top', 'title' => t('Paying by'), 'data' => $method->cartReviewTitle()); $result = $method->cartReview($order); if (is_array($result)) {