forked from sampart/WhiteOctoberTCPDFBundle
-
Notifications
You must be signed in to change notification settings - Fork 1
/
WrepTCPDFBundle.php
48 lines (41 loc) · 1.44 KB
/
WrepTCPDFBundle.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace Wrep\TCPDFBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class WrepTCPDFBundle extends Bundle
{
/**
* Ran on bundle boot, our TCPDF configuration constants
* get defined here if required
*/
public function boot()
{
// Define our TCPDF variables
$config = $this->container->getParameter('wrep_tcpdf.tcpdf');
// Add our cache path to the correct section of the configuration
$cacheDir = $this->container->getParameter('wrep_tcpdf.cache_dir');
$config['k_path_cache'] = $cacheDir;
$config['k_path_url_cache'] = $cacheDir;
// Define TCPDF constants it needs
if ($config['k_tcpdf_external_config'])
{
foreach ($config as $k => $v)
{
$constKey = strtoupper($k);
// All K_ constants are required
if (preg_match("/^k_/i", $k))
{
if (!defined($constKey))
{
define($constKey, $this->container->getParameterBag()->resolveValue($v));
}
}
// and one special value which TCPDF will use if present
if (strtolower($k) == "pdf_font_name_main" && !defined($constKey))
{
define($constKey, $v);
}
}
}
}
}