You are here

RegistrationDateStringField.php in RNG - Events and Registrations 3.x

Same filename and directory in other branches
  1. 8.2 src/Plugin/views/field/RegistrationDateStringField.php

File

src/Plugin/views/field/RegistrationDateStringField.php
View source
<?php

namespace Drupal\rng\Plugin\views\field;

use Drupal\Core\Form\FormStateInterface;
use Drupal\Component\Utility\Random;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;

/**
 * A handler to provide a field that is completely custom by the administrator.
 *
 * @ingroup views_field_handlers
 *
 * @ViewsField("registration_date_string_field")
 */
class RegistrationDateStringField extends FieldPluginBase {

  /**
   * {@inheritdoc}
   */
  public function usesGroupBy() {
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function query() {

    // Do nothing -- to override the parent query.
  }

  /**
   * {@inheritdoc}
   */
  protected function defineOptions() {
    $options = parent::defineOptions();
    $options['hide_alter_empty'] = [
      'default' => FALSE,
    ];
    return $options;
  }

  /**
   * {@inheritdoc}
   */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function render(ResultRow $values) {
    $object = $values->_entity;
    if ($object && method_exists($object, 'getDateString')) {
      return $object
        ->getDateString();
    }
  }

}

Classes

Namesort descending Description
RegistrationDateStringField A handler to provide a field that is completely custom by the administrator.