uc_gc_client-8.x-1.x-dev/src/Plugin/views/field/PaymentType.php

src/Plugin/views/field/PaymentType.php
<?php

namespace Drupal\uc_gc_client\Plugin\views\field;

use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;

/**
 * Field handler to flag the node type.
 *
 * @ingroup views_field_handlers
 *
 * @ViewsField("gc_payment_type")
 */
class PaymentType extends FieldPluginBase {

  /**
   * {@inheritdoc}
   */
  public function query() {
    // Leave empty to avoid a query on this field.
  }

  /**
   * {@inheritdoc}
   */
  public function render(ResultRow $values) {
    $ucid = $values->_entity->id();
    $type = db_select('uc_gc_client', 'c')
      ->fields('c', ['type'])
      ->condition('ucid', $ucid)
      ->execute()->fetchField();
    if (isset($type)) {
      if ($type == 'S') {
        return $this->t('Subscription');
      }
      elseif ($type == 'P') {
        return $this->t('One-off payments');
      }
    }
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc