diff --git a/web/modules/custom/popsu_uniqdate/config/schema/popsu_uniqdate.schema.yml b/web/modules/custom/popsu_uniqdate/config/schema/popsu_uniqdate.schema.yml new file mode 100644 index 00000000..59e1897b --- /dev/null +++ b/web/modules/custom/popsu_uniqdate/config/schema/popsu_uniqdate.schema.yml @@ -0,0 +1,3 @@ +views.field.view_computed_date_unique: + type: views_field + label: 'Computed Date Unique' \ No newline at end of file diff --git a/web/modules/custom/popsu_uniqdate/src/Plugin/Field/FieldType/ComputedUniqDate.php b/web/modules/custom/popsu_uniqdate/src/Plugin/Field/FieldType/ComputedUniqDate.php new file mode 100644 index 00000000..f11f6aa0 --- /dev/null +++ b/web/modules/custom/popsu_uniqdate/src/Plugin/Field/FieldType/ComputedUniqDate.php @@ -0,0 +1,52 @@ +entityTypeManager = \Drupal::entityTypeManager(); + } + + /** + * Compute the values. + */ + protected function computeValue() { + // $query = \Drupal::entityQuery('node') + $entity = $this->getEntity(); + // $storage = \Drupal::service('entity_type.manager')->getStorage('node'); + $dates = $entity->get('field_date')->getValue(); + asort($dates); + $last_date = array_pop($dates); + $this->list[0] = $this->createItem(0, $last_date); + } + +} diff --git a/web/modules/custom/popsu_uniqdate/src/Plugin/views/field/ViewsComputedDateUnique.php b/web/modules/custom/popsu_uniqdate/src/Plugin/views/field/ViewsComputedDateUnique.php new file mode 100644 index 00000000..e811cf07 --- /dev/null +++ b/web/modules/custom/popsu_uniqdate/src/Plugin/views/field/ViewsComputedDateUnique.php @@ -0,0 +1,36 @@ +_entity; + $uniqdate = $entity->get('computed_date_unique')->getValue(); + return $uniqdate[0]['value']; + // $dates = $entity->get('field_date')->getvalue(); + // asort($dates); + // return array_pop($dates); + } + + /** + * {@inheritdoc} + */ + public function query() { + // This function exists to override parent query function. + // Do nothing. + } +} \ No newline at end of file