-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TASK] Avoid objectManager usage in PdfView class
- Loading branch information
Showing
1 changed file
with
17 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
<?php | ||
/* * ************************************************************* | ||
|
||
/**************************************************************** | ||
* Copyright notice | ||
* | ||
* (C) 2015 Mittwald CM Service GmbH & Co. KG <[email protected]> | ||
* (C) Mittwald CM Service GmbH & Co. KG <[email protected]> | ||
* | ||
* All rights reserved | ||
* | ||
|
@@ -21,7 +22,7 @@ | |
* GNU General Public License for more details. | ||
* | ||
* This copyright notice MUST APPEAR in all copies of the script! | ||
* ************************************************************* */ | ||
***************************************************************/ | ||
|
||
namespace Mittwald\Web2pdf\View; | ||
|
||
|
@@ -32,17 +33,8 @@ | |
use TYPO3\CMS\Core\Core\Environment; | ||
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface; | ||
use TYPO3\CMS\Fluid\View\StandaloneView; | ||
|
||
|
||
/** | ||
* PDFView | ||
* | ||
* @author Kevin Purrmann <[email protected]>, Purrmann Websolutions | ||
* @package Mittwald | ||
* @subpackage Web2Pdf\View | ||
*/ | ||
class PdfView | ||
{ | ||
|
||
|
@@ -64,11 +56,6 @@ class PdfView | |
*/ | ||
protected $pdfLinkUtility; | ||
|
||
/** | ||
* @var ObjectManagerInterface | ||
*/ | ||
protected $objectManager; | ||
|
||
/** | ||
* PdfView constructor. | ||
* @param ModuleOptions $options | ||
|
@@ -78,13 +65,11 @@ class PdfView | |
public function __construct( | ||
ModuleOptions $options, | ||
FilenameUtility $fileNameUtility, | ||
PdfLinkUtility $pdfLinkUtility, | ||
ObjectManagerInterface $objectManager | ||
PdfLinkUtility $pdfLinkUtility | ||
) { | ||
$this->options = $options; | ||
$this->fileNameUtility = $fileNameUtility; | ||
$this->pdfLinkUtility = $pdfLinkUtility; | ||
$this->objectManager = $objectManager; | ||
} | ||
|
||
|
||
|
@@ -160,20 +145,17 @@ protected function getPdfObject(): Mpdf | |
$topMargin = ($this->options->getPdfTopMargin()) ? $this->options->getPdfTopMargin() : '15'; | ||
$styleSheet = ($this->options->getPdfStyleSheet()) ? $this->options->getPdfStyleSheet() : 'print'; | ||
|
||
/* @var $pdf Mpdf */ | ||
$pdf = $this->objectManager->get( | ||
Mpdf::class, [ | ||
'format' => $pageFormat, | ||
'default_font_size' => 12, | ||
'margin_left' => $leftMargin, | ||
'margin_right' => $rightMargin, | ||
'margin_top' => $topMargin, | ||
'margin_bottom' => $bottomMargin, | ||
'orientation' => $pageOrientation, | ||
'tempDir' => Environment::getVarPath() . '/web2pdf', | ||
'fontDir' => ExtensionManagementUtility::extPath('web2pdf') . 'Resources/Public/Fonts', | ||
] | ||
); | ||
$pdf = new Mpdf([ | ||
'format' => $pageFormat, | ||
'default_font_size' => 12, | ||
'margin_left' => $leftMargin, | ||
'margin_right' => $rightMargin, | ||
'margin_top' => $topMargin, | ||
'margin_bottom' => $bottomMargin, | ||
'orientation' => $pageOrientation, | ||
'tempDir' => Environment::getVarPath() . '/web2pdf', | ||
'fontDir' => ExtensionManagementUtility::extPath('web2pdf') . 'Resources/Public/Fonts', | ||
]); | ||
|
||
$pdf->SetMargins($leftMargin, $rightMargin, $topMargin); | ||
|
||
|
@@ -190,8 +172,7 @@ protected function getPdfObject(): Mpdf | |
*/ | ||
protected function getPartial($templateName, $arguments = array()): string | ||
{ | ||
/* @var $partial \TYPO3\CMS\Fluid\View\StandaloneView */ | ||
$partial = $this->objectManager->get(StandaloneView::class); | ||
$partial = GeneralUtility::makeInstance(StandaloneView::class); | ||
$partial->setLayoutRootPaths($this->options->getLayoutRootPaths()); | ||
$partial->setPartialRootPaths($this->options->getPartialRootPaths()); | ||
$partial->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName(end($partial->getPartialRootPaths())) . 'Pdf/' . ucfirst($templateName) . '.html'); | ||
|