1 | <?php |
||
20 | class VisualPaginatorExtension extends DI\CompilerExtension |
||
21 | { |
||
22 | /** |
||
23 | * @var array |
||
24 | */ |
||
25 | protected $defaults = [ |
||
26 | 'templateFile' => NULL |
||
27 | ]; |
||
28 | |||
29 | public function loadConfiguration() |
||
30 | { |
||
31 | $config = DI\Config\Helpers::merge($this->getConfig(), $this->defaults); |
||
32 | $builder = $this->getContainerBuilder(); |
||
33 | |||
34 | // Define components |
||
35 | $paginator = $builder->addFactoryDefinition($this->prefix('paginator')) |
||
36 | ->setImplement('IPub\VisualPaginator\Components\IControl') |
||
37 | ->addTag('cms.components') |
||
38 | ->getResultDefinition() |
||
39 | ->setType('IPub\VisualPaginator\Components\Control') |
||
40 | ->setArguments([new Nette\PhpGenerator\PhpLiteral('$templateFile')]) |
||
41 | ->addTag(DI\Extensions\InjectExtension::TAG_INJECT); |
||
42 | |||
43 | if ($config['templateFile']) { |
||
44 | $paginator->addSetup('$service->setTemplateFile(?)', [$config['templateFile']]); |
||
45 | } |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * @param Nette\Configurator $config |
||
50 | * @param string $extensionName |
||
51 | */ |
||
52 | public static function register(Nette\Configurator $config, $extensionName = 'visualPaginator') |
||
58 | |||
59 | /** |
||
60 | * Return array of directories, that contain resources for translator. |
||
61 | * |
||
62 | * @return string[] |
||
63 | */ |
||
64 | function getTranslationResources() |
||
70 | } |
||
71 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.