1 | <?php |
||
36 | 1 | final class PhoneUIExtension extends DI\CompilerExtension |
|
37 | { |
||
38 | /** |
||
39 | * @return void |
||
40 | */ |
||
41 | public function loadConfiguration() |
||
42 | { |
||
43 | // Get container builder |
||
44 | 1 | $builder = $this->getContainerBuilder(); |
|
45 | |||
46 | 1 | $builder->addDefinition($this->prefix('phoneUI')) |
|
47 | 1 | ->setType(PhoneUI\PhoneUI::class) |
|
48 | 1 | ->setInject(FALSE); |
|
49 | |||
50 | // Register template helpers |
||
51 | $builder->addDefinition($this->prefix('helpers')) |
||
52 | ->setType(PhoneUI\Templating\Helpers::class) |
||
53 | ->setFactory($this->prefix('@phoneUI') . '::createTemplateHelpers') |
||
54 | ->setInject(FALSE); |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * {@inheritdoc} |
||
59 | */ |
||
60 | public function beforeCompile() |
||
61 | { |
||
62 | parent::beforeCompile(); |
||
63 | |||
64 | // Get container builder |
||
65 | $builder = $this->getContainerBuilder(); |
||
66 | |||
67 | // Install extension latte macros |
||
68 | $latteFactory = $builder->getDefinition($builder->getByType(Bridges\ApplicationLatte\ILatteFactory::class) ?: 'nette.latteFactory'); |
||
69 | |||
70 | $latteFactory |
||
71 | ->addSetup('IPub\PhoneUI\Latte\Macros::install(?->getCompiler())', ['@self']) |
||
72 | ->addSetup('addFilter', ['phone', [$this->prefix('@helpers'), 'phone']]) |
||
73 | ->addSetup('addFilter', ['getPhoneNumberService', [$this->prefix('@helpers'), 'getPhoneNumberService']]); |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * @param Nette\Configurator $config |
||
78 | * @param string $extensionName |
||
79 | * |
||
80 | * @return void |
||
81 | */ |
||
82 | public static function register(Nette\Configurator $config, string $extensionName = 'phoneUI') |
||
88 | } |
||
89 |