Ejemplo n.º 1
0
 /**
  * @param  string   $websiteId
  * @param  array    $columnValues
  * @param  boolean  $useColumnsValuesId
  * @return \Orm\Entity\Album
  */
 public function create($websiteId, array $columnValues, $useColumnsValuesId = false)
 {
     $album = new Album();
     if ($useColumnsValuesId && isset($columnValues['id'])) {
         $album->setId($columnValues['id']);
     } else {
         $album->setNewGeneratedId();
     }
     if (isset($columnValues['name'])) {
         $album->setName($columnValues['name']);
     }
     $album->setWebsiteid($websiteId);
     try {
         $entityManager = $this->getEntityManager();
         $entityManager->persist($album);
         $entityManager->flush();
         $entityManager->refresh($album);
     } catch (Exception $e) {
         throw new CmsException(404, __METHOD__, __LINE__, null, $e);
     }
     return $album;
 }
Ejemplo n.º 2
0
 /**
  * @param  string $websiteId
  * @param  array  $importedAlbums
  *
  * @return \Orm\Entity\Album  default album
  */
 protected function createDefaultAlbum($websiteId, &$importedAlbums)
 {
     // already created default Album
     if ($this->defaultAlbum !== null && $this->defaultAlbum instanceof \Orm\Entity\Album && $this->defaultAlbum->getId() !== null) {
         return $this->defaultAlbum;
     }
     $albumDao = $this->getAlbumDao();
     $foundAlbum = $albumDao->getByWebsiteIdAndName($websiteId, $this->defaultAlbumName);
     if (is_array($foundAlbum) && count($foundAlbum) > 0) {
         $this->defaultAlbum = array_shift($foundAlbum);
     } else {
         $columnValues = array('name' => $this->defaultAlbumName);
         $album = $albumDao->create($websiteId, $columnValues);
         $this->defaultAlbum = $album;
         $importedAlbums[$album->getId()] = array('id' => $album->getId(), 'name' => $album->getName());
     }
     return $this->defaultAlbum;
 }
Ejemplo n.º 3
0
 /**
  * {@inheritDoc}
  */
 public function setNewGeneratedId()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setNewGeneratedId', array());
     return parent::setNewGeneratedId();
 }