From 397358ec5a6c63e6d5b178bc697b6a951acebcd3 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sat, 5 Oct 2019 14:18:56 +0200 Subject: [PATCH] Add IFormNode::addClasses() Close #3083 --- .../lib/system/form/builder/IFormNode.class.php | 10 ++++++++++ .../lib/system/form/builder/TFormNode.class.php | 16 ++++++++++++++++ .../container/TabTabMenuFormContainer.class.php | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/system/form/builder/IFormNode.class.php b/wcfsetup/install/files/lib/system/form/builder/IFormNode.class.php index b5a27314ad..4b2d060ba2 100644 --- a/wcfsetup/install/files/lib/system/form/builder/IFormNode.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/IFormNode.class.php @@ -22,6 +22,16 @@ interface IFormNode { */ public function addClass($class); + /** + * Adds the given CSS classes to this node and returns this node. + * + * @param string[] $classes names added CSS classes + * @return static this node + * + * @throws \InvalidArgumentException if any of the given classes is invalid + */ + public function addClasses(array $classes); + /** * Adds a dependency on the value of a `IFormField` so that this node is * only available if the field satisfies the given dependency and returns diff --git a/wcfsetup/install/files/lib/system/form/builder/TFormNode.class.php b/wcfsetup/install/files/lib/system/form/builder/TFormNode.class.php index 9f9975d048..813f0304fe 100644 --- a/wcfsetup/install/files/lib/system/form/builder/TFormNode.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/TFormNode.class.php @@ -75,6 +75,22 @@ trait TFormNode { return $this; } + /** + * Adds the given CSS classes to this node and returns this node. + * + * @param string[] $classes names added CSS classes + * @return static this node + * + * @throws \InvalidArgumentException if any of the given classes is invalid + */ + public function addClasses(array $classes) { + foreach ($classes as $class) { + $this->addClass($class); + } + + return $this; + } + /** * Adds a dependency on the value of a `IFormField` so that this node is * only available if the field satisfies the given dependency and returns diff --git a/wcfsetup/install/files/lib/system/form/builder/container/TabTabMenuFormContainer.class.php b/wcfsetup/install/files/lib/system/form/builder/container/TabTabMenuFormContainer.class.php index bde3e0ec5d..382e902b52 100644 --- a/wcfsetup/install/files/lib/system/form/builder/container/TabTabMenuFormContainer.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/container/TabTabMenuFormContainer.class.php @@ -20,6 +20,6 @@ class TabTabMenuFormContainer extends TabMenuFormContainer implements ITabFormCo * @inheritDoc */ public function __construct() { - $this->addClass('tabMenuContainer')->addClass('tabMenuContent'); + $this->addClasses(['tabMenuContainer', 'tabMenuContent']); } } -- 2.20.1