rng-3.x-dev/src/Plugin/views/field/RegistrationDateStringField.php
src/Plugin/views/field/RegistrationDateStringField.php
<?php namespace Drupal\rng\Plugin\views\field; 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 render(ResultRow $values) { $object = $values->_entity; if ($object && method_exists($object, 'getDateString')) { return $object->getDateString(); } } }