Ejemplo n.º 1
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());
 }
Ejemplo n.º 2
0
 /**
  * @param Link $link
  * @return $this
  */
 public function addLink(Link $link)
 {
     $link->setUserId($this);
     $this->links[] = $link;
     return $this;
 }