/**
  * @Route("/icap_blog/widget/blog/{id}/config", name="icap_blog_widget_blog_configure", requirements={"id" = "\d+"})
  * @Method("POST")
  */
 public function updateWidgetBlog(Request $request, WidgetInstance $widgetInstance)
 {
     if (!$this->get('security.authorization_checker')->isGranted('edit', $widgetInstance)) {
         throw new AccessDeniedException();
     }
     $resourceNode = $this->getWidgetManager()->getResourceNodeOfWidgetBlog($widgetInstance);
     $entityManager = $this->getDoctrine()->getManager();
     /** @var \icap\BlogBundle\Entity\WidgetBlog $widgetBlog */
     $widgetBlog = $entityManager->getRepository('IcapBlogBundle:WidgetBlog')->findOneByWidgetInstance($widgetInstance);
     if (null === $widgetBlog) {
         $widgetBlog = new WidgetBlog();
         $widgetBlog->setResourceNode($resourceNode)->setWidgetInstance($widgetInstance);
     }
     /** @var Form $form */
     $form = $this->get('form.factory')->create($this->get('icap_blog.form.widget_blog'), $widgetBlog);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $entityManager->persist($widgetBlog);
         $entityManager->flush();
         return new Response('', Response::HTTP_NO_CONTENT);
     }
     return $this->render('IcapBlogBundle:widget:blogConfigure.html.twig', array('form' => $form->createView(), 'widgetInstance' => $widgetInstance));
 }
 /**
  * @DI\Observe("widget_blog_configuration")
  */
 public function onWidgetBlogConfigure(ConfigureWidgetEvent $event)
 {
     $widgetBlog = new WidgetBlog();
     $widgetBlog->setResourceNode($this->widgetManager->getResourceNodeOfWidgetBlog($event->getInstance()));
     $form = $this->formFactory->create($this->widgetBlogType, $widgetBlog);
     $content = $this->templatingEngine->render('IcapBlogBundle:widget:blogConfigure.html.twig', array('form' => $form->createView(), 'widgetInstance' => $event->getInstance()));
     $event->setContent($content);
 }