|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the Superdesk Web Publisher Core Bundle. |
|
7
|
|
|
* |
|
8
|
|
|
* Copyright 2016 Sourcefabric z.ú. and contributors. |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please see the |
|
11
|
|
|
* AUTHORS and LICENSE files distributed with this source code. |
|
12
|
|
|
* |
|
13
|
|
|
* @copyright 2016 Sourcefabric z.ú |
|
14
|
|
|
* @license http://www.superdesk.org/license |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
namespace SWP\Bundle\CoreBundle\Theme; |
|
18
|
|
|
|
|
19
|
|
|
use Sylius\Bundle\ThemeBundle\Context\ThemeContextInterface; |
|
20
|
|
|
use Takeit\Bundle\AmpHtmlBundle\Loader\ThemeLoaderInterface; |
|
21
|
|
|
|
|
22
|
|
|
final class AmpThemeLoader implements ThemeLoaderInterface |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* @var \Twig_Loader_Filesystem |
|
26
|
|
|
*/ |
|
27
|
|
|
private $filesystem; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var ThemeContextInterface |
|
31
|
|
|
*/ |
|
32
|
|
|
private $themeContext; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var string |
|
36
|
|
|
*/ |
|
37
|
|
|
private $themePath; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @param \Twig_Loader_Filesystem $filesystem |
|
41
|
|
|
* @param ThemeContextInterface $themeContext |
|
42
|
|
|
* @param string $themePath |
|
43
|
|
|
*/ |
|
44
|
2 |
|
public function __construct( |
|
45
|
|
|
\Twig_Loader_Filesystem $filesystem, |
|
46
|
|
|
ThemeContextInterface $themeContext, |
|
47
|
|
|
string $themePath |
|
48
|
|
|
) { |
|
49
|
2 |
|
$this->filesystem = $filesystem; |
|
50
|
2 |
|
$this->themeContext = $themeContext; |
|
51
|
2 |
|
$this->themePath = $themePath; |
|
52
|
2 |
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* {@inheritdoc} |
|
56
|
|
|
*/ |
|
57
|
2 |
|
public function load() |
|
58
|
|
|
{ |
|
59
|
2 |
|
$this->filesystem->addPath( |
|
60
|
2 |
|
sprintf('%s/%s', $this->themeContext->getTheme()->getPath(), trim($this->themePath, '/')), |
|
61
|
2 |
|
ThemeLoaderInterface::THEME_NAMESPACE |
|
62
|
|
|
); |
|
63
|
2 |
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|