From fafe64dac7bff7f274b939722feb9bba9ae50dbd Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Fri, 29 May 2020 21:48:45 +0100 Subject: [PATCH] Refactor talks to keep existing tests passing References #78 --- web/modules/custom/custom/custom.module | 2 +- .../src/Entity/{Node.php => Node/Talk.php} | 22 +++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) rename web/modules/custom/custom/src/Entity/{Node.php => Node/Talk.php} (52%) diff --git a/web/modules/custom/custom/custom.module b/web/modules/custom/custom/custom.module index c7ad0c0..e1181b1 100644 --- a/web/modules/custom/custom/custom.module +++ b/web/modules/custom/custom/custom.module @@ -13,7 +13,7 @@ use Drupal\discoverable_entity_bundle_classes\Storage\Node\NodeStorage; * Implements hook_entity_type_build(). */ function custom_entity_type_build(array &$entityTypes): void { - /** @var \Drupal\Core\Entity\EntityTypeInterface[] $entityTypes */ + /** @var \Drupal\Core\Entity\EntityTypeInterface[] $entityTypes */ if (isset($entityTypes['node'])) { $entityTypes['node']->setStorageClass(NodeStorage::class); } diff --git a/web/modules/custom/custom/src/Entity/Node.php b/web/modules/custom/custom/src/Entity/Node/Talk.php similarity index 52% rename from web/modules/custom/custom/src/Entity/Node.php rename to web/modules/custom/custom/src/Entity/Node/Talk.php index eecbb67..25db19e 100644 --- a/web/modules/custom/custom/src/Entity/Node.php +++ b/web/modules/custom/custom/src/Entity/Node/Talk.php @@ -1,14 +1,22 @@ hasField('field_events')) { - return NULL; - } - return Collection::make($this->get('field_events')->referencedEntities()) ->map(fn(ParagraphInterface $event) => $event->get('field_date') ->getString())