Skip to content

Commit

Permalink
Changed the PDF file request in all other places
Browse files Browse the repository at this point in the history
  • Loading branch information
rogyar committed Jul 2, 2018
1 parent 70fed74 commit 31df140
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ public function __construct(
*/
public function massAction(AbstractCollection $collection)
{
$pdf = $this->pdfCreditmemo->getPdf($collection);
$fileContent = ['type' => 'string', 'value' => $pdf->render(), 'rm' => true];

return $this->fileFactory->create(
sprintf('creditmemo%s.pdf', $this->dateTime->date('Y-m-d_H-i-s')),
$this->pdfCreditmemo->getPdf($collection)->render(),
$fileContent,
DirectoryList::VAR_DIR,
'application/pdf'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function __construct(

/**
* @return ResponseInterface|\Magento\Backend\Model\View\Result\Forward
* @throws \Exception
*/
public function execute()
{
Expand All @@ -69,9 +70,11 @@ public function execute()
$date = $this->_objectManager->get(
\Magento\Framework\Stdlib\DateTime\DateTime::class
)->date('Y-m-d_H-i-s');
$fileContent = ['type' => 'string', 'value' => $pdf->render(), 'rm' => true];

return $this->_fileFactory->create(
\creditmemo::class . $date . '.pdf',
$pdf->render(),
$fileContent,
DirectoryList::VAR_DIR,
'application/pdf'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,12 @@ public function __construct(
*/
public function massAction(AbstractCollection $collection)
{
$pdf = $this->pdfInvoice->getPdf($collection);
$fileContent = ['type' => 'string', 'value' => $pdf->render(), 'rm' => true];

return $this->fileFactory->create(
sprintf('invoice%s.pdf', $this->dateTime->date('Y-m-d_H-i-s')),
$this->pdfInvoice->getPdf($collection)->render(),
$fileContent,
DirectoryList::VAR_DIR,
'application/pdf'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function __construct(

/**
* @return ResponseInterface|void
* @throws \Exception
*/
public function execute()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public function __construct(
*
* @param AbstractCollection $collection
* @return ResponseInterface|ResultInterface
* @throws \Exception
*/
protected function massAction(AbstractCollection $collection)
{
Expand All @@ -85,9 +86,12 @@ protected function massAction(AbstractCollection $collection)
$this->messageManager->addError(__('There are no printable documents related to selected orders.'));
return $this->resultRedirectFactory->create()->setPath($this->getComponentRefererUrl());
}
$pdf = $this->pdfCreditmemo->getPdf($creditmemoCollection->getItems());
$fileContent = ['type' => 'string', 'value' => $pdf->render(), 'rm' => true];

return $this->fileFactory->create(
sprintf('creditmemo%s.pdf', $this->dateTime->date('Y-m-d_H-i-s')),
$this->pdfCreditmemo->getPdf($creditmemoCollection->getItems())->render(),
$fileContent,
DirectoryList::VAR_DIR,
'application/pdf'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public function __construct(
* @return ResponseInterface|\Magento\Backend\Model\View\Result\Redirect
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @throws \Exception
*/
protected function massAction(AbstractCollection $collection)
{
Expand Down Expand Up @@ -142,10 +143,11 @@ protected function massAction(AbstractCollection $collection)
foreach ($documents as $document) {
$pdf->pages = array_merge($pdf->pages, $document->pages);
}
$fileContent = ['type' => 'string', 'value' => $pdf->render(), 'rm' => true];

return $this->fileFactory->create(
sprintf('docs%s.pdf', $this->dateTime->date('Y-m-d_H-i-s')),
$pdf->render(),
$fileContent,
DirectoryList::VAR_DIR,
'application/pdf'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public function __construct(
*
* @param AbstractCollection $collection
* @return ResponseInterface|ResultInterface
* @throws \Exception
*/
protected function massAction(AbstractCollection $collection)
{
Expand All @@ -83,9 +84,12 @@ protected function massAction(AbstractCollection $collection)
$this->messageManager->addError(__('There are no printable documents related to selected orders.'));
return $this->resultRedirectFactory->create()->setPath($this->getComponentRefererUrl());
}
$pdf = $this->pdfInvoice->getPdf($invoicesCollection->getItems());
$fileContent = ['type' => 'string', 'value' => $pdf->render(), 'rm' => true];

return $this->fileFactory->create(
sprintf('invoice%s.pdf', $this->dateTime->date('Y-m-d_H-i-s')),
$this->pdfInvoice->getPdf($invoicesCollection->getItems())->render(),
$fileContent,
DirectoryList::VAR_DIR,
'application/pdf'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public function __construct(
*
* @param AbstractCollection $collection
* @return ResponseInterface|\Magento\Backend\Model\View\Result\Redirect
* @throws \Exception
*/
protected function massAction(AbstractCollection $collection)
{
Expand All @@ -87,9 +88,13 @@ protected function massAction(AbstractCollection $collection)
$this->messageManager->addError(__('There are no printable documents related to selected orders.'));
return $this->resultRedirectFactory->create()->setPath($this->getComponentRefererUrl());
}

$pdf = $this->pdfShipment->getPdf($shipmentsCollection->getItems());
$fileContent = ['type' => 'string', 'value' => $pdf->render(), 'rm' => true];

return $this->fileFactory->create(
sprintf('packingslip%s.pdf', $this->dateTime->date('Y-m-d_H-i-s')),
$this->pdfShipment->getPdf($shipmentsCollection->getItems())->render(),
$fileContent,
DirectoryList::VAR_DIR,
'application/pdf'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ public function __construct(
*/
public function massAction(AbstractCollection $collection)
{
$pdf = $this->pdfShipment->getPdf($collection);
$fileContent = ['type' => 'string', 'value' => $pdf->render(), 'rm' => true];

return $this->fileFactory->create(
sprintf('packingslip%s.pdf', $this->dateTime->date('Y-m-d_H-i-s')),
$this->pdfShipment->getPdf($collection)->render(),
$fileContent,
DirectoryList::VAR_DIR,
'application/pdf'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public function __construct(

/**
* @return ResponseInterface|\Magento\Backend\Model\View\Result\Forward
* @throws \Exception
*/
public function execute()
{
Expand All @@ -63,9 +64,11 @@ public function execute()
$date = $this->_objectManager->get(
\Magento\Framework\Stdlib\DateTime\DateTime::class
)->date('Y-m-d_H-i-s');
$fileContent = ['type' => 'string', 'value' => $pdf->render(), 'rm' => true];

return $this->_fileFactory->create(
'packingslip' . $date . '.pdf',
$pdf->render(),
$fileContent,
DirectoryList::VAR_DIR,
'application/pdf'
);
Expand Down

0 comments on commit 31df140

Please sign in to comment.