*/
protected $boxes = [];
+ /**
+ * identifier to boxes
+ * @var Box[]
+ */
+ protected $boxesByIdentifier = [];
+
/**
* @inheritDoc
*/
foreach ($boxList as $box) {
if (!isset($this->boxes[$box->position])) $this->boxes[$box->position] = [];
$this->boxes[$box->position][] = $box;
+ $this->boxesByIdentifier[$box->identifier] = $box;
}
}
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;
+ }
}