public function emailAction(Request $request, $id)
    {
        $em = $this->getDoctrine()->getManager();
        /** @var Newsletter $entity */
        $entity = $em->getRepository('CoreBundle:BaseActor')->find($id);
        
        $form = $this->createForm(ActorEmailType::class, null, array('email' => $entity->getEmail()));
       
        if($request->getMethod() == 'POST'){
            $form->handleRequest($request);

            if ($form->isValid()) {
                //Get params
                $data = $form->getData();
                $email = $data['email'];            
                if($entity->getEmail() == $email){
                    
                    $news = new Newsletter();
                    $news->setTitle($data['subject']);
                    $news->setBody($data['body']);
                    $news->setActive(true);
                    $em->persist($news);
                    
                    $shipping = new NewsletterShipping();
                    $shipping->setNewsletter($news);
                    $shipping->setActor($entity);
                    $shipping->setTotalSent(1);
                    $shipping->setType(NewsletterShipping::TYPE_PERSONAL);
                    $em->persist($shipping);
                    $em->flush();
                    
                    $this->get('core.mailer')->sendActorEmail($email, $data['subject'], $data['body']);
                    
                    //if come from popup
                    if ($request->isXMLHttpRequest()) {         
                        return new JsonResponse(array(
                                    'id' => $shipping->getId()
                                ));
                    }

                    $this->get('session')->getFlashBag()->add('success', 'user.email.created');
                    return $this->redirect($this->generateUrl('core_baseactor_show', array('id' => $entity->getId())));
                }

            }
        }

        return array(
            'entity' => $entity,
            'form'   => $form->createView(),
        );
    }