From: Marcel Werk Date: Sun, 19 Jun 2016 22:01:07 +0000 (+0200) Subject: Added method to get a certain box by identifier X-Git-Tag: 3.0.0_Beta_1~1394 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=897c4d76cc941f16685b776b9c73b66fd4014271;p=GitHub%2FWoltLab%2FWCF.git Added method to get a certain box by identifier --- 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; + } }