예제 #1
0
    /**
     * Activate (make it available for authors) a content type.
     * Checks that the content isn't dirty (as far as eMS knows the Mapping in Elasticsearch is up-to-date).
     *
     * @param integer $id        	
     * @param Request $request
     * 
     * @Route("/content-type/activate/{contentType}", name="contenttype.activate"))
     * @Method({"POST"})
     */
    public function activateAction(ContentType $contentType, Request $request)
    {
        /** @var EntityManager $em */
        $em = $this->getDoctrine()->getManager();
        if ($contentType->getDirty()) {
            $this->addFlash('warning', 'Content type "' . $contentType->getName() . '" is dirty (its mapping migth be out-of date).
					Try to update its mapping.');
            return $this->redirectToRoute('contenttype.index');
        }
        $contentType->setActive(true);
        $em->persist($contentType);
        $em->flush();
        return $this->redirectToRoute('contenttype.index');
    }