/** * {@inheritDoc} */ public function setWebsiteid($websiteid) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'setWebsiteid', array($websiteid)); return parent::setWebsiteid($websiteid); }
/** * Copies all MediaItems to new website id * * @param string $sourceWebsiteId * @param string $newWebsiteId * @return boolean */ public function copyMediaToNewWebsite($sourceWebsiteId, $newWebsiteId) { /** @var \Orm\Entity\Media[] $sourceMedias */ $sourceMedias = $this->getEntitymanager()->getRepository('Orm\\Entity\\Media')->findBy(array('websiteid' => $sourceWebsiteId)); if ($sourceMedias === null) { throw new CmsException('232', __METHOD__, __LINE__); } foreach ($sourceMedias as $sourceMedia) { $newMedia = new Media(); $newMedia->setId($sourceMedia->getId()); $newMedia->setWebsiteid($newWebsiteId); $newMedia->setAlbumId($sourceMedia->getAlbumId()); $newMedia->setName($sourceMedia->getName()); $newMedia->setFilename($sourceMedia->getFilename()); $newMedia->setSize($sourceMedia->getSize()); $newMedia->setLastmod(time()); $newMedia->setFile($sourceMedia->getFile()); $newMedia->setType($sourceMedia->getType()); $newMedia->setMimetype($sourceMedia->getMimetype()); $newMedia->setDateUploaded($sourceMedia->getDateUploaded()); $newMedia->setExtension($sourceMedia->getExtension()); $this->getEntitymanager()->persist($newMedia); $this->getEntitymanager()->flush(); } $this->clearEntityManager(); return true; }