Ojs\JournalBundle\Controller\JournalThemeController::cloneGlobalThemeAction PHP Метод

cloneGlobalThemeAction() публичный Метод

public cloneGlobalThemeAction ( Request $request, integer $id ) : RedirectResponse
$request Symfony\Component\HttpFoundation\Request
$id integer
Результат Symfony\Component\HttpFoundation\RedirectResponse
    public function cloneGlobalThemeAction(Request $request, $id)
    {
        $useTheme = $request->query->has('use') ? true : false;
        $themeType = $request->get('type');
        $journal = $this->get('ojs.journal_service')->getSelectedJournal();
        if (!$this->isGranted('VIEW', $journal, 'theme')) {
            throw new AccessDeniedException("You are not authorized for view this page");
        }
        $em = $this->getDoctrine()->getManager();
        $theme = null;
        if ($themeType == 'journal') {
            //disable journal filter for get all journal themes
            $GLOBALS['Ojs\\JournalBundle\\Entity\\JournalTheme#journalFilter'] = false;
            $theme = $em->getRepository('OjsJournalBundle:JournalTheme')->find($id);
        } elseif ($themeType == 'global') {
            $theme = $em->getRepository('OjsAdminBundle:AdminJournalTheme')->find($id);
        }
        $this->throw404IfNotFound($theme);
        $clonedTheme = new JournalTheme();
        $clonedTheme->setJournal($journal)->setTitle($theme->getTitle() . ' [cloned]')->setCss($theme->getCss())->setPublic(false);
        $em->persist($clonedTheme);
        $em->flush();
        if ($useTheme) {
            $journal->setTheme($clonedTheme);
            $em->persist($journal);
            $em->flush();
            $this->successFlashBag('successfully.cloned.global.theme.and.used');
        } else {
            $this->successFlashBag('successfully.cloned.global.theme');
        }
        return $this->redirectToRoute('ojs_journal_theme_index', ['journalId' => $journal->getId()]);
    }