nodeStorage = $entityTypeManager->getStorage('node'); } public function getFor(Post $post): Collection { $query = $this->nodeStorage->getQuery(); // Ensure that the current node ID is not returned as a related post. $query->condition('nid', $post->id(), '!='); /** @var array $postIds */ $postIds = $query->execute(); $posts = $this->nodeStorage->loadMultiple($postIds); return (new Collection($posts))->values(); } }