From e9b76e86c6c2846d44bdf2808ff586538566786f Mon Sep 17 00:00:00 2001 From: adamsokolowski06 <37297805+adamsokolowski06@users.noreply.github.com> Date: Wed, 18 Sep 2024 11:03:13 +0200 Subject: [PATCH] Create content context (#9) Co-authored-by: Eirik Stanghelle Morland --- src/ContentContext.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/ContentContext.php diff --git a/src/ContentContext.php b/src/ContentContext.php new file mode 100644 index 0000000..4bc8087 --- /dev/null +++ b/src/ContentContext.php @@ -0,0 +1,33 @@ +getStorage('taxonomy_term') + ->loadByProperties(['name' => $name]); + + if ($term) { + $term = reset($term); + $term->setUnpublished(); + $term->save(); + } + else { + throw new \Exception("Term with name '$name' not found"); + } + } + +}