1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Symfony\Component\HttpKernel\Kernel; |
4
|
|
|
use Symfony\Component\Config\Loader\LoaderInterface; |
5
|
|
|
|
6
|
|
|
class AppKernel extends Kernel |
7
|
|
|
{ |
8
|
|
|
private $projectDir; |
|
|
|
|
9
|
|
|
|
10
|
|
|
public function registerBundles() |
11
|
|
|
{ |
12
|
|
|
$bundles = [ |
13
|
|
|
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(), |
14
|
|
|
new \Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), |
15
|
|
|
new \Symfony\Bundle\TwigBundle\TwigBundle(), |
16
|
|
|
new \Symfony\Bundle\WebServerBundle\WebServerBundle(), |
17
|
|
|
new \Translation\Bundle\TranslationBundle(), |
18
|
|
|
new \AppBundle\AppBundle(), |
19
|
|
|
|
20
|
|
|
new \Translation\PlatformAdapter\Loco\Bridge\Symfony\TranslationAdapterLocoBundle(), |
21
|
|
|
new \Translation\PlatformAdapter\Flysystem\Bridge\Symfony\TranslationAdapterFlysystemBundle(), |
22
|
|
|
//new \Translation\PlatformAdapter\PhraseApp\Bridge\Symfony\TranslationAdapterPhraseAppBundle(), |
|
|
|
|
23
|
|
|
]; |
24
|
|
|
|
25
|
|
|
return $bundles; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function getRootDir() |
29
|
|
|
{ |
30
|
|
|
return __DIR__; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function getCacheDir() |
34
|
|
|
{ |
35
|
|
|
return sys_get_temp_dir().'/php-translation/var/cache/'.$this->getEnvironment(); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function getLogDir() |
39
|
|
|
{ |
40
|
|
|
return sys_get_temp_dir().'/php-translation/var/logs'; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function registerContainerConfiguration(LoaderInterface $loader) |
44
|
|
|
{ |
45
|
|
|
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml'); |
46
|
|
|
$config = getcwd().'/translation.yml'; |
47
|
|
|
if (file_exists($config)) { |
48
|
|
|
$loader->load($config); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Gets the application root dir (path of the project's LICENSE file). |
54
|
|
|
* |
55
|
|
|
* @return string The project root dir |
56
|
|
|
*/ |
57
|
|
|
public function getProjectDir() |
58
|
|
|
{ |
59
|
|
|
if (null === $this->projectDir) { |
60
|
|
|
$r = new \ReflectionObject($this); |
61
|
|
|
$dir = $rootDir = dirname($r->getFileName()); |
|
|
|
|
62
|
|
|
while (!file_exists($dir.'/LICENSE')) { |
63
|
|
|
if ($dir === dirname($dir)) { |
64
|
|
|
return $this->projectDir = parent::getProjectDir(); |
65
|
|
|
} |
66
|
|
|
$dir = dirname($dir); |
67
|
|
|
} |
68
|
|
|
$this->projectDir = $dir; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
return $this->projectDir; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|