From: Matthias Schmidt Date: Sat, 5 Oct 2019 12:18:56 +0000 (+0200) Subject: Add IFormNode::addClasses() X-Git-Tag: 5.2.0_Beta_2~9 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=397358ec5a6c63e6d5b178bc697b6a951acebcd3;p=GitHub%2FWoltLab%2FWCF.git Add IFormNode::addClasses() Close #3083 --- 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']); } }