-
Notifications
You must be signed in to change notification settings - Fork 112
/
BootTwig.php
40 lines (33 loc) · 1018 Bytes
/
BootTwig.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
<?php
namespace OFFLINE\Mall\Classes\Registration;
use OFFLINE\Mall\Classes\Utils\Money;
use System\Twig\Extension as TwigExtension;
use System\Twig\Loader as TwigLoader;
use Twig\Environment;
trait BootTwig
{
public function registerTwigEnvironment()
{
$this->app->singleton('mall.twig.environment', function () {
$twig = new Environment(new TwigLoader, ['auto_reload' => true]);
$twig->addExtension(new TwigExtension);
return $twig;
});
}
public function registerMarkupTags()
{
$filters = [
'money' => function (...$args) {
return app(Money::class)->format(...$args);
},
];
// Check the translate plugin is installed
if ( ! class_exists('RainLab\Translate\Behaviors\TranslatableModel')) {
$filters['_'] = ['Lang', 'get'];
$filters['__'] = ['Lang', 'choice'];
}
return [
'filters' => $filters,
];
}
}