You are here

public function DataField::render in Ubercart 8.4

Renders the field.

Parameters

\Drupal\views\ResultRow $values: The values retrieved from a single row of a view's query result.

Return value

string|\Drupal\Component\Render\MarkupInterface The rendered output. If the output is safe it will be wrapped in an object that implements MarkupInterface. If it is empty or unsafe it will be a string.

Overrides FieldPluginBase::render

File

payment/uc_credit/src/Plugin/views/field/DataField.php, line 20

Class

DataField
Field handler to display encrypted credit card data.

Namespace

Drupal\uc_credit\Plugin\views\field

Code

public function render(ResultRow $values) {

  // Initialize the encryption key and class.
  $key = uc_credit_encryption_key();
  $crypt = \Drupal::service('uc_store.encryption');
  $data = unserialize($values->{$this->field_alias});
  if (isset($data['cc_data'])) {
    $cc_data = $crypt
      ->decrypt($key, $data['cc_data']);
    if (strpos($cc_data, ':') === FALSE) {
      $cc_data = base64_decode($cc_data);
    }
    $cc_data = unserialize($cc_data);
    if (isset($cc_data[$this->definition['cc field']])) {
      return $cc_data[$this->definition['cc field']];
    }
  }
}