/** * Actual object collection * @throws Exception If collection config is not set. * @return Collection Collection from the export config. */ public function collection() { if ($this->collection) { return $this->collection; } if (!$this->collectionConfig()) { throw new Exception('No collection config set for ' . $this->objType() . ' in Charcoal\\Admin\\Helper\\Exporter'); } $collection = new CollectionLoader(['logger' => $this->logger, 'factory' => $this->modelFactory()]); $collection->setModel($this->proto()); $collection->setData($this->collectionConfig()); $this->collection = $collection->load(); return $this->collection; }