From 897c4d76cc941f16685b776b9c73b66fd4014271 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Mon, 20 Jun 2016 00:01:07 +0200 Subject: [PATCH] Added method to get a certain box by identifier --- .../files/lib/system/box/BoxHandler.class.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/wcfsetup/install/files/lib/system/box/BoxHandler.class.php b/wcfsetup/install/files/lib/system/box/BoxHandler.class.php index 7dae4ea260..dba652554d 100644 --- a/wcfsetup/install/files/lib/system/box/BoxHandler.class.php +++ b/wcfsetup/install/files/lib/system/box/BoxHandler.class.php @@ -24,6 +24,12 @@ class BoxHandler extends SingletonFactory { */ protected $boxes = []; + /** + * identifier to boxes + * @var Box[] + */ + protected $boxesByIdentifier = []; + /** * @inheritDoc */ @@ -43,6 +49,7 @@ class BoxHandler extends SingletonFactory { foreach ($boxList as $box) { if (!isset($this->boxes[$box->position])) $this->boxes[$box->position] = []; $this->boxes[$box->position][] = $box; + $this->boxesByIdentifier[$box->identifier] = $box; } } @@ -100,4 +107,18 @@ class BoxHandler extends SingletonFactory { return []; } + + /** + * Returns the box with given identifier. + * + * @param string $identifier + * @return Box|null + */ + public function getBoxByIdentifier($identifier) { + if (isset($this->boxesByIdentifier[$identifier])) { + return $this->boxesByIdentifier[$identifier]; + } + + return null; + } } -- 2.20.1