From be5ad2f3d7bf82926b0c75c06cd3583945c8e8eb Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Thu, 9 Nov 2023 17:17:08 +0100 Subject: [PATCH] Rely on feature --- galette/lib/Galette/Entity/Adherent.php | 19 ++------------- galette/lib/Galette/Features/Dependencies.php | 23 ++++++++++++++++--- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/galette/lib/Galette/Entity/Adherent.php b/galette/lib/Galette/Entity/Adherent.php index cf6361db9..916c59cc3 100644 --- a/galette/lib/Galette/Entity/Adherent.php +++ b/galette/lib/Galette/Entity/Adherent.php @@ -191,15 +191,6 @@ class Adherent private $_row_classes; private $_self_adh = false; - protected array $_deps = array( - 'picture' => true, - 'groups' => true, - 'dues' => true, - 'parent' => false, - 'children' => false, - 'dynamics' => false, - 'socials' => false - ); private $zdb; private $preferences; @@ -234,16 +225,10 @@ class Adherent if ($deps !== null) { if (is_array($deps)) { - $this->_deps = array_merge( - $this->_deps, - $deps - ); + $this->setDeps($deps); } elseif ($deps === false) { //no dependencies - $this->_deps = array_fill_keys( - array_keys($this->_deps), - false - ); + $this->disableAllDeps(); } else { Analog::log( '$deps should be an array, ' . gettype($deps) . ' given!', diff --git a/galette/lib/Galette/Features/Dependencies.php b/galette/lib/Galette/Features/Dependencies.php index b24a96e15..ec91bcb02 100644 --- a/galette/lib/Galette/Features/Dependencies.php +++ b/galette/lib/Galette/Features/Dependencies.php @@ -77,6 +77,22 @@ trait Dependencies 'socials' => false ); + /** + * Set dependencies + * + * @param array $deps Dependencies to set + * + * @return $this + */ + public function setDeps(array $deps): self + { + $this->_deps = array_merge( + $this->_deps, + $deps + ); + return $this; + } + /** * Reset dependencies to load * @@ -84,9 +100,10 @@ trait Dependencies */ public function disableAllDeps(): self { - foreach ($this->_deps as &$dep) { - $dep = false; - } + $this->_deps = array_fill_keys( + array_keys($this->_deps), + false + ); return $this; } -- 2.39.2