protected function createAlbums(Tx_Yag_Domain_Model_Gallery $gallery) { $albumRepository = $this->objectManager->get('Tx_Yag_Domain_Repository_AlbumRepository'); /* @var $albumRepository Tx_Yag_Domain_Repository_AlbumRepository */ $first = true; for ($i = 1; $i <= $this->albumsPerGalleryCount; $i++) { $album = new Tx_Yag_Domain_Model_Album(); $album->setName('TestAlbum ' . $i); $album->setDescription('Created on ' . date('d.m.Y H:i:s')); $album->setGallery($gallery); $albumRepository->add($album); if ($first) { $gallery->setThumbAlbum($album); $first = FALSE; } $this->createItems($album); } }
/** * Creates a new album and imports images from zip into that album * * TODO this method is not yet used and hence not tested! * * @param Tx_Yag_Domain_Model_Gallery $gallery Gallery to add album to * @param string $albumName Name of album to be created * @throws Exception */ public function createNewAlbumAndImportFromZipAction(Tx_Yag_Domain_Model_Gallery $gallery, $albumName) { $album = new Tx_Yag_Domain_Model_Album(); $album->setName($albumName); $album->addGallery($gallery); $gallery->addAlbum($album); $this->albumRepository->add($album); $persistenceManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager'); $persistenceManager->persistAll(); if (!$album->getUid() > 0) { throw new Exception('Album hat keine UID!'); } $importer = Tx_Yag_Domain_Import_ZipImporter_ImporterBuilder::getInstance()->getZipImporterInstanceForAlbum($album); $importer->runImport(); $this->view->assign('album', $album); }