/** * Update playists with current theme playlists definitions. * * @param Theme $theme * @param array $themePlaylists * * @return bool */ public function updateThemePlaylists($theme, $themePlaylists) { $newThemePlaylists = $this->buildNewThemePlaylists($themePlaylists); foreach ($newThemePlaylists as $playlistName => $themePlaylist) { $playlist = $this->em->getRepository('Newscoop\\Entity\\Playlist')->getPlaylistByTitle($playlistName)->getOneOrNullResult(); if (!$playlist) { $playlist = new Playlist(); $playlist->setName($playlistName); $this->em->persist($playlist); } $themes = $playlist->getThemes(); $themes[$theme->getId()] = $themePlaylist['templates']; $playlist->setThemes($themes); } $this->em->flush(); return true; }
public function setName($name) { $this->__load(); return parent::setName($name); }
public function saveDataAction() { $playlistId = $this->_request->getParam('id', null); $playlist = null; $playlistName = $this->_request->getParam('name', ''); // TODO make a service if (is_numeric($playlistId)) { $playlist = $this->playlistRepository->find($playlistId); if (!is_null($playlist) && trim($playlistName) != '') { $playlist->setName($playlistName); } } else { $playlist = new Playlist(); $playlist->setName(trim($playlistName) != '' ? $playlistName : getGS('Playlist') . strftime('%F')); } $playlist = $this->playlistRepository->save($playlist, $this->_request->getParam('articles')); if (!$playlist instanceof \Exception) { $this->_helper->service->getService('dispatcher')->notify('playlist.save', new GenericEvent($this, array('id' => $playlist->getId()))); $this->view->playlistId = $playlist->getId(); $this->view->playlistName = $playlist->getName(); } else { $this->view->error = $playlist->getFile() . ":" . $playlist->getLine() . " " . $playlist->getMessage(); } }