Skip to content
Snippets Groups Projects
Commit 2f9a2746 authored by Owen Bush's avatar Owen Bush
Browse files

Inherit standard options for computed fields in views

parent c2955f11
No related branches found
No related tags found
No related merge requests found
...@@ -36,6 +36,7 @@ function recurring_events_views_data_alter(array &$data) { ...@@ -36,6 +36,7 @@ function recurring_events_views_data_alter(array &$data) {
'title' => t('Event instance title'), 'title' => t('Event instance title'),
'help' => t('The inherited title of an event instance.'), 'help' => t('The inherited title of an event instance.'),
'id' => 'eventinstance_title', 'id' => 'eventinstance_title',
'field_name' => 'title',
], ],
]; ];
...@@ -46,6 +47,7 @@ function recurring_events_views_data_alter(array &$data) { ...@@ -46,6 +47,7 @@ function recurring_events_views_data_alter(array &$data) {
'title' => t('Event instance description'), 'title' => t('Event instance description'),
'help' => t('The inherited description of an event instance.'), 'help' => t('The inherited description of an event instance.'),
'id' => 'eventinstance_description', 'id' => 'eventinstance_description',
'field_name' => 'description',
], ],
]; ];
} }
...@@ -4,6 +4,7 @@ namespace Drupal\recurring_events\Plugin\views\field; ...@@ -4,6 +4,7 @@ namespace Drupal\recurring_events\Plugin\views\field;
use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow; use Drupal\views\ResultRow;
use Drupal\views\Plugin\views\field\EntityField;
/** /**
* Field handler to show the inherited event instance description. * Field handler to show the inherited event instance description.
...@@ -12,21 +13,6 @@ use Drupal\views\ResultRow; ...@@ -12,21 +13,6 @@ use Drupal\views\ResultRow;
* *
* @ViewsField("eventinstance_description") * @ViewsField("eventinstance_description")
*/ */
class EventInstanceDescription extends FieldPluginBase { class EventInstanceDescription extends EntityField {
/**
* {@inheritdoc}
*/
public function query() {
// Leave empty to avoid a query on this field.
}
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
$event = $values->_entity;
return $event->getInheritedDescription();
}
} }
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
namespace Drupal\recurring_events\Plugin\views\field; namespace Drupal\recurring_events\Plugin\views\field;
use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\Plugin\views\field\EntityField;
use Drupal\views\ResultRow;
/** /**
* Field handler to show the inherited event instance title. * Field handler to show the inherited event instance title.
...@@ -12,21 +11,6 @@ use Drupal\views\ResultRow; ...@@ -12,21 +11,6 @@ use Drupal\views\ResultRow;
* *
* @ViewsField("eventinstance_title") * @ViewsField("eventinstance_title")
*/ */
class EventInstanceTitle extends FieldPluginBase { class EventInstanceTitle extends EntityField {
/**
* {@inheritdoc}
*/
public function query() {
// Leave empty to avoid a query on this field.
}
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
$event = $values->_entity;
return $event->getInheritedTitle();
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment