applicationBox = $applicationBox; return $this; } /** * @return \appbox */ public function getApplicationBox() { if ($this->applicationBox instanceof \appbox) { return $this->applicationBox; } if (null === $this->applicationBox && $this instanceof \Pimple && $this->offsetExists('phraseanet.appbox')) { $this->applicationBox = function () { return $this['phraseanet.appbox']; }; } if (null === $this->applicationBox) { throw new \LogicException('Application box instance or locator was not set'); } $instance = call_user_func($this->applicationBox); if (!$instance instanceof \appbox) { throw new \LogicException(sprintf( 'Expects locator to return instance of "%s", got "%s"', \appbox::class, is_object($instance) ? get_class($instance) : gettype($instance) )); } $this->applicationBox = $instance; return $this->applicationBox; } /** * @return CollectionService */ public function getCollectionService() { return $this['services.collection']; } /** * Find a registered Databoxes. * * @return \databox[] */ public function getDataboxes() { return $this->getApplicationBox()->get_databoxes(); } /** * Find a registered Databox by its id. * * @param int $id * @return \databox */ public function findDataboxById($id) { return $this->getApplicationBox()->get_databox($id); } }