/**
  * @param Dropzone $dropzone
  * @param Drop     $drop
  * @param Document $document
  */
 public function __construct(Dropzone $dropzone, Drop $drop, Document $document)
 {
     $documentsDetails = array();
     foreach ($drop->getDocuments() as $document) {
         $documentsDetails[] = $document->toArray();
     }
     $details = array('dropzone' => array('id' => $dropzone->getId()), 'drop' => array('id' => $drop->getId(), 'documents' => $documentsDetails), 'document' => $document->toArray());
     parent::__construct($dropzone->getResourceNode(), $details);
 }
 /**
  * @param Dropzone $dropzone
  * @param Drop     $drop
  * @param Document $document
  */
 public function __construct(Dropzone $dropzone, Drop $drop, Document $document)
 {
     $details = array('dropzone' => array('id' => $dropzone->getId()), 'drop' => array('id' => $drop->getId(), 'owner' => array('id' => $drop->getUser()->getId(), 'lastName' => $drop->getUser()->getLastName(), 'firstName' => $drop->getUser()->getFirstName(), 'username' => $drop->getUser()->getUsername())), 'document' => $document->toArray());
     parent::__construct($dropzone->getResourceNode(), $details);
 }
 /**
  * @Route(
  *      "/{resourceId}/open/resource/{documentId}",
  *      name="icap_dropzone_open_resource",
  *      requirements={"resourceId" = "\d+", "documentId" = "\d+"}
  * )
  * @ParamConverter("dropzone", class="IcapDropzoneBundle:Dropzone", options={"id" = "resourceId"})
  * @ParamConverter("document", class="IcapDropzoneBundle:Document", options={"id" = "documentId"})
  * @ParamConverter("user", options={"authenticatedUser" = true})
  * @Template()
  */
 public function openResourceAction(Dropzone $dropzone, Document $document, $user)
 {
     $this->get('icap.manager.dropzone_voter')->isAllowToOpen($dropzone);
     if ($document->getType() == 'url') {
         return $this->redirect($document->getUrl());
     } elseif ($document->getType() == 'text' or $document->getType() == 'resource' or $document->getType() == 'file') {
         $this->get('claroline.temporary_access_resource_manager')->addTemporaryAccess($document->getResourceNode(), $user);
         $event = new LogDocumentOpenEvent($dropzone, $document->getDrop(), $document);
         $this->dispatch($event);
         if ($document->getResourceNode()->getResourceType()->getName() == 'file') {
             return $this->redirect($this->generateUrl('claro_resource_download') . '?ids[]=' . $document->getResourceNode()->getId());
         } else {
             return $this->redirect($this->generateUrl('claro_resource_open', array('resourceType' => $document->getResourceNode()->getResourceType()->getName(), 'node' => $document->getResourceNode()->getId())));
         }
     }
 }