PaymentStatusLabel.php in Payment 8.2
File
src/Plugin/views/field/PaymentStatusLabel.php
View source
<?php
namespace Drupal\payment\Plugin\views\field;
use Drupal\payment\Plugin\Payment\Status\PaymentStatusManagerInterface;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;
use Symfony\Component\DependencyInjection\ContainerInterface;
class PaymentStatusLabel extends FieldPluginBase {
protected $paymentStatusManager;
public function __construct(array $configuration, $plugin_id, $plugin_definition, PaymentStatusManagerInterface $payment_status_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->paymentStatusManager = $payment_status_manager;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('plugin.manager.payment.status'));
}
public function render(ResultRow $values) {
$plugin_id = $this
->getValue($values);
$plugin_definition = $this->paymentStatusManager
->getDefinition($plugin_id);
return $plugin_definition['label'];
}
}