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