public function createShare(Request $request, ShareAction $share)
 {
     $return = array();
     $resourceId = $request->get("resourceId");
     if ($resourceId === null) {
         $url = $request->get("url");
         if ($url === null) {
             throw new BadRequestHttpException();
         }
         $share->setUrl($url);
         $return["url"] = $url;
         $title = $request->get("title");
         $share->setTitle($title);
         if ($title !== null) {
             $return["title"] = $title;
         }
     } else {
         $resourceNode = $this->resourceNodeRepository->find($resourceId);
         $share->setResource($resourceNode);
         $return["title"] = $resourceNode->getName();
         $return["url"] = $this->router->generate("claro_resource_open_short", array("node" => $resourceNode->getId()), true);
     }
     $network = $request->get("network");
     $share->setNetwork($network);
     $this->em->persist($share);
     $this->wallItemManager->createWallItem($share);
     $this->em->flush();
     return $return;
 }
 /**
  * @Route("/share", name="icap_socialmedia_share")
  * @ParamConverter("user", converter="current_user", options={"allowAnonymous"=true})
  * @Template()
  *
  * @param Request $request
  * @param User    $user
  *
  * @return bool
  */
 public function shareAction(Request $request, User $user = null)
 {
     $share = new ShareAction();
     $share->setUser($user);
     $network = $request->get('network');
     $options = $this->getShareActionManager()->createShare($request, $share);
     $this->dispatchShareEvent($share);
     $response = array();
     if ($network !== null) {
         $socialShare = new SocialShare();
         $shareLink = $socialShare->getNetwork($network)->getShareLink($options['url'], array($options['title']));
         $response = new RedirectResponse($shareLink);
     }
     return $response;
 }
예제 #3
0
 protected function dispatchShareEvent(ShareAction $share)
 {
     $resource = $share->getResource();
     if ($resource !== null) {
         $event = new LogSocialmediaShareEvent($share);
         return $this->dispatch($event);
     }
 }
 public function __construct(ShareAction $share)
 {
     $this->details = array('share' => array('network' => $share->getNetwork()));
     parent::__construct($share->getResource(), $this->details);
 }