setIssue() 공개 메소드

Set issue
public setIssue ( Issue $issue ) : IssueFile
$issue Issue
리턴 IssueFile
 /**
  * Imports the given issue file
  * @param int    $id    Issue file's ID
  * @param int    $oldId Old issue file's ID
  * @param Issue  $issue File's issue
  * @param string $slug  Journal's slug
  */
 public function importIssueFile($id, $oldId, $issue, $slug)
 {
     $this->consoleOutput->writeln("Reading issue file #" . $id . "... ", true);
     $issueFileSql = "SELECT * FROM issue_files WHERE file_id = :id LIMIT 1";
     $issueFileStatement = $this->dbalConnection->prepare($issueFileSql);
     $issueFileStatement->bindValue('id', $id);
     $issueFileStatement->execute();
     $galleysSql = "SELECT galley_id, issue_id, locale, label FROM issue_galleys " . "WHERE issue_id = :issue_id AND file_id = :id";
     $galleysStatement = $this->dbalConnection->prepare($galleysSql);
     $galleysStatement->bindValue('issue_id', $oldId);
     $galleysStatement->bindValue('id', $id);
     $galleysStatement->execute();
     $pkpIssueFile = $issueFileStatement->fetch();
     $pkpGalleys = $galleysStatement->fetchAll();
     foreach ($pkpGalleys as $galley) {
         $locale = !empty($galley['locale']) ? mb_substr($galley['locale'], 0, 2, 'UTF-8') : 'en';
         $label = !empty($galley['label']) ? $galley['label'] : '-';
         $filename = sprintf('imported/%s/%s.%s', $galley['issue_id'], $galley['galley_id'], FileHelper::$mimeToExtMap[$pkpIssueFile['file_type']]);
         $issueFile = new IssueFile();
         $issueFile->setFile($filename);
         $issueFile->setIssue($issue);
         $issueFile->setVersion(0);
         $issueFile->setType(0);
         // Fill translatable fields
         $issueFile->setCurrentLocale($locale);
         $issueFile->setTitle($label);
         $issueFile->setDescription('-');
         $history = $this->em->getRepository(FileHistory::class)->findOneBy(['fileName' => $filename]);
         if (!$history) {
             $history = new FileHistory();
             $history->setFileName($filename);
             $history->setOriginalName($pkpIssueFile['original_file_name']);
             $history->setType('issuefiles');
             $this->em->persist($history);
         }
         $source = sprintf('%s/issue/download/%s/%s', $slug, $galley['issue_id'], $galley['galley_id']);
         $target = sprintf('/../web/uploads/issuefiles/imported/%s/%s.%s', $galley['issue_id'], $galley['galley_id'], FileHelper::$mimeToExtMap[$pkpIssueFile['file_type']]);
         $pendingDownload = new PendingDownload();
         $pendingDownload->setSource($source);
         $pendingDownload->setTarget($target);
         $this->em->persist($pendingDownload);
         $this->em->persist($issueFile);
     }
 }
예제 #2
0
 public function testDelete()
 {
     $em = $this->em;
     $entity = new IssueFile();
     $entity->setCurrentLocale('en');
     $entity->setTitle('Demo File');
     $entity->setDescription('A file');
     $entity->setFile('issue.txt');
     $entity->setLangCode('en');
     $entity->setType(0);
     $entity->setVersion(0);
     $issue = $em->getRepository('OjsJournalBundle:Issue')->find('1');
     $entity->setIssue($issue);
     $em->persist($entity);
     $em->flush();
     $id = $entity->getId();
     $this->logIn();
     $client = $this->client;
     $token = $this->generateToken('ojs_journal_issue_file' . $id);
     $client->request('DELETE', '/journal/1/issue/1/file/' . $id . '/delete', array('_token' => $token));
     $this->assertStatusCode(302, $client);
 }
예제 #3
0
 /**
  * Displays a form to create a new IssueFile entity.
  *
  * @param $issueId
  * @return Response
  */
 public function newAction($issueId)
 {
     $journal = $this->get('ojs.journal_service')->getSelectedJournal();
     $em = $this->getDoctrine()->getManager();
     if (!$this->isGranted('CREATE', $journal, 'issues')) {
         throw new AccessDeniedException('You are not authorized for create  issue file for this journal!');
     }
     /** @var Issue $issue */
     $issue = $em->getRepository('OjsJournalBundle:Issue')->find($issueId);
     $this->throw404IfNotFound($issue);
     $entity = new IssueFile();
     $entity->setIssue($issue);
     $form = $this->createCreateForm($entity, $journal->getId())->add('create', 'submit', array('label' => 'c'));
     return $this->render('OjsJournalBundle:IssueFile:new.html.twig', array('entity' => $entity, 'form' => $form->createView()));
 }