code formatter
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace Sasedev\MpdfBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
@@ -15,16 +14,18 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
* @author sasedev <sinus@sasedev.net>
|
||||
* Created on: 5 juil. 2020 @ 22:25:09
|
||||
*/
|
||||
class SasedevMpdfExtension extends Extension {
|
||||
class SasedevMpdfExtension extends Extension
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritdoc}
|
||||
*
|
||||
*/
|
||||
public function load(array $configs, ContainerBuilder $container) {
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
$locator = new FileLocator(__DIR__ . '/../Resources/config');
|
||||
$loader = new Loader\YamlFileLoader($container, $locator);
|
||||
$loader->load('services.yaml');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,9 +31,7 @@ class MpdfFactory
|
||||
*/
|
||||
public function __construct(string $cacheDir)
|
||||
{
|
||||
|
||||
$this->cacheDir = $cacheDir;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,7 +40,6 @@ class MpdfFactory
|
||||
*/
|
||||
public function getDefaultConstructorParams(): array
|
||||
{
|
||||
|
||||
return [
|
||||
'mode' => '',
|
||||
'format' => 'A4',
|
||||
@@ -56,7 +53,6 @@ class MpdfFactory
|
||||
'margin_footer' => 9,
|
||||
'orientation' => 'P'
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,10 +61,8 @@ class MpdfFactory
|
||||
*/
|
||||
public function getDefaultConfigVariables(): array
|
||||
{
|
||||
|
||||
$configObject = new ConfigVariables();
|
||||
return $configObject->getDefaults();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,10 +71,8 @@ class MpdfFactory
|
||||
*/
|
||||
public function getDefaultFontVariables(): array
|
||||
{
|
||||
|
||||
$fontObject = new FontVariables();
|
||||
return $fontObject->getDefaults();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,20 +84,17 @@ class MpdfFactory
|
||||
*/
|
||||
public function createMpdfObject($mpdfArgs = [])
|
||||
{
|
||||
|
||||
$defaultOptions = \array_merge($this->getDefaultConstructorParams(), $this->getDefaultConfigVariables(), $this->getDefaultFontVariables(),
|
||||
[
|
||||
'mode' => 'utf-8',
|
||||
'format' => 'A4',
|
||||
'tempDir' => $this->cacheDir
|
||||
]);
|
||||
$defaultOptions = \array_merge($this->getDefaultConstructorParams(), $this->getDefaultConfigVariables(), $this->getDefaultFontVariables(), [
|
||||
'mode' => 'utf-8',
|
||||
'format' => 'A4',
|
||||
'tempDir' => $this->cacheDir
|
||||
]);
|
||||
|
||||
$argOptions = \array_merge($defaultOptions, $mpdfArgs);
|
||||
|
||||
$mPdf = new Mpdf($argOptions);
|
||||
|
||||
return $mPdf;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,7 +108,6 @@ class MpdfFactory
|
||||
*/
|
||||
public function createInlineResponse(Mpdf $mPdf, ?string $filename = null, ?int $status = 200, ?array $headers = [])
|
||||
{
|
||||
|
||||
$content = $mPdf->Output('', Destination::STRING_RETURN);
|
||||
|
||||
$defaultHeaders = [
|
||||
@@ -129,19 +117,15 @@ class MpdfFactory
|
||||
'Expires' => 'Sat, 26 Jul 1997 05:00:00 GMT',
|
||||
'Last-Modified' => gmdate('D, d M Y H:i:s') . ' GMT'
|
||||
];
|
||||
if (false == \is_null($filename))
|
||||
{
|
||||
if (false == \is_null($filename)) {
|
||||
$defaultHeaders['Content-disposition'] = sprintf('inline; filename="%s"', $filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$defaultHeaders['Content-disposition'] = sprintf('inline; filename="%s"', 'file.pdf');
|
||||
}
|
||||
|
||||
$headers = \array_merge($defaultHeaders, $headers);
|
||||
|
||||
return new Response($content, $status, $headers);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,7 +139,6 @@ class MpdfFactory
|
||||
*/
|
||||
public function createDownloadResponse(Mpdf $mPdf, string $filename, ?int $status = 200, ?array $headers = [])
|
||||
{
|
||||
|
||||
$content = $mPdf->Output('', Destination::STRING_RETURN);
|
||||
|
||||
$defaultHeaders = [
|
||||
@@ -174,7 +157,5 @@ class MpdfFactory
|
||||
$headers = \array_merge($defaultHeaders, $headers);
|
||||
|
||||
return new Response($content, $status, $headers);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,9 +22,6 @@ class SasedevMpdfBundle extends Bundle
|
||||
*/
|
||||
public function getContainerExtension()
|
||||
{
|
||||
|
||||
return new SasedevMpdfExtension();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user