Esempio n. 1
0
 /**
  * @param Link $link
  * @param $categoryId
  */
 public function saveLink(Link $link, $categoryId)
 {
     $category = $this->categoryManager->getCategoryById($categoryId);
     $link->setCategoryId($category);
     $category->addLink($link);
     $this->repository->saveLink($link);
 }
Esempio n. 2
0
 /**
  * @Route("/new")
  */
 public function newLink(Request $request)
 {
     $link = new Link();
     $link->setOwner($this->get('security.context')->getToken()->getUser());
     $form = $this->createForm(new LinkType(), $link);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($link);
         $em->flush();
         return $this->redirect('/');
     }
     return $this->render('AppBundle:Default:new.html.twig', array('form' => $form->createView()));
 }
Esempio n. 3
0
 /**
  * @param Request $request
  * @param FormInterface $form
  */
 public function process(Request $request, FormInterface $form)
 {
     $form->handleRequest($request);
     if ($form->isValid()) {
         $data = $form->getData();
         $idea = new IdeaEntity();
         $idea->setTitle($data['title'])->setDescription($data['description'])->setUser($this->getUserFromTokenStorage());
         $this->ideaService->saveIdea($idea);
         if ($data['youtube-flag'] === true) {
             $youtubeLink = new Link();
             $youtubeLink->setIdea($idea)->setType(Link::TYPE_YOUTUBE)->setLink($data['youtube-value']);
             $this->linkService->saveLink($youtubeLink);
         }
     }
 }
 /**
  * @Route("/addlink", name="addLink")
  */
 public function addLinkAction(Request $request)
 {
     $link = new Link();
     $user = $this->getUser();
     $link->setUser($user);
     $form = $this->createForm(new LinkType(), $link);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($link);
         $em->flush();
         $this->addFlash('notice', 'Your link was added!');
         return new RedirectResponse($this->generateUrl('addLink'));
     }
     return $this->render('AppBundle/addlink.html.twig', array('form' => $form->createView()));
 }
Esempio n. 5
0
 /**
  * @Route("/link/add-ajax", name="link-add-ajax")
  * @param Request $request
  * @return string|Response
  */
 public function addNewAjaxAction(Request $request)
 {
     $link = new Link();
     $link->setHeading($request->get('title'));
     $link->setLink($request->get('link'));
     $link->setDescription($request->get('desc'));
     $link->setUserId($this->getUser());
     $catId = (int) $request->get('category');
     $link->setTags($request->get('tags'));
     if ($request->request->get('article')['privacy'] == 'internal') {
         $link->setPrivate(true);
     } else {
         $link->setPrivate(false);
     }
     $this->get('link_manager')->saveLink($link, $catId);
     return new Response('Created link ' . $link->getHeading());
 }
Esempio n. 6
0
 /**
  * @param Link $link
  * @return $this
  */
 public function addLink(Link $link)
 {
     $this->links[] = $link;
     $link->setCategoryId($this);
     return $this;
 }
 /**
  * {@inheritDoc}
  */
 public function getTags()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getTags', array());
     return parent::getTags();
 }
Esempio n. 8
0
 /**
  * @param Link $link
  * @return $this
  */
 public function addLink(Link $link)
 {
     $link->setUserId($this);
     $this->links[] = $link;
     return $this;
 }
 /**
  * Creates a form to delete a Link entity.
  *
  * @param Link $link The Link entity
  *
  * @return \Symfony\Component\Form\Form The form
  */
 private function createDeleteForm(Link $link)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('link_delete', array('id' => $link->getId())))->setMethod('DELETE')->getForm();
 }