Skip to content

Commit

Permalink
remove broken upgrade script, improve errors handling in publication …
Browse files Browse the repository at this point in the history
…edit form
  • Loading branch information
ahilles107 committed Nov 20, 2015
1 parent 456fdbc commit 6864636
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.

This file was deleted.

25 changes: 13 additions & 12 deletions newscoop/library/Newscoop/Services/PlaylistsService.php
Expand Up @@ -205,24 +205,25 @@ public function checkIfThemePlaylistsAreUpToDate($theme, $themePlaylists)
public function updateThemePlaylists($theme, $themePlaylists)
{
$newThemePlaylists = $this->buildNewThemePlaylists($themePlaylists);
if (is_array($newThemePlaylists)) {
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);
}

foreach ($newThemePlaylists as $playlistName => $themePlaylist) {
$playlist = $this->em->getRepository('Newscoop\Entity\Playlist')->getPlaylistByTitle($playlistName)->getOneOrNullResult();
if (!$playlist) {
$playlist = new Playlist();
$playlist->setName($playlistName);
$themes = $playlist->getThemes();
$themes[$theme->getId()] = $themePlaylist['templates'];

$this->em->persist($playlist);
$playlist->setThemes($themes);
}

$themes = $playlist->getThemes();
$themes[$theme->getId()] = $themePlaylist['templates'];

$playlist->setThemes($themes);
$this->em->flush();
}

$this->em->flush();

return true;
}

Expand Down
Expand Up @@ -65,8 +65,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'output' => 1,
'publication' => $options['publication']->getId(),
'language' => $language,
)
);
));

$frontThemeChoices = array('0' => 'publications.form_type.label.follow_current_issue_theme');
$choosedTheme = 0;
Expand Down

0 comments on commit 6864636

Please sign in to comment.