From 710e217f12bc20d7f2189ff95ca13ef8daccc71c Mon Sep 17 00:00:00 2001 From: Keith Lau <86580032+klaukl@users.noreply.github.com> Date: Mon, 19 Feb 2024 10:07:15 +1100 Subject: [PATCH] add func --- src/TideSiteHelper.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/TideSiteHelper.php b/src/TideSiteHelper.php index 9818027e..e26eccc3 100644 --- a/src/TideSiteHelper.php +++ b/src/TideSiteHelper.php @@ -120,6 +120,31 @@ public function getAllSites() { return $sites; } + + /** + * Returns all sites. + * + * @return \Drupal\taxonomy\TermInterface[] + * List of sites. + */ + public function getAllSitesAndSiteSections() { + $sites = []; + + try { + $terms = $this->entityTypeManager->getStorage('taxonomy_term') + ->loadByProperties(['vid' => 'sites']); + /** @var \Drupal\taxonomy\TermInterface $site */ + foreach ($terms as $site) { + $sites[$site->id()] = $site; + } + } + catch (\Exception $exception) { + watchdog_exception('tide_site', $exception); + } + + return $sites; + } + /** * Loads a Site term by ID. *