/usr/share/php/ApiGen/DI/ApiGenExtension.php is in php-apigen 4.1.2-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | <?php
/**
* This file is part of the ApiGen (http://apigen.org)
*
* For the full copyright and license information, please view
* the file license.md that was distributed with this source code.
*/
namespace ApiGen\DI;
use Nette\DI\CompilerExtension;
class ApiGenExtension extends CompilerExtension
{
const TAG_CONSOLE_COMMAND = 'console.command';
const TAG_LATTE_FILTER = 'latte.filter';
const TAG_TEMPLATE_GENERATOR = 'template.generator';
public function loadConfiguration()
{
$this->loadServicesFromConfig();
$this->setupTemplating();
}
public function beforeCompile()
{
$builder = $this->getContainerBuilder();
$builder->prepareClassList();
$this->setupConsole();
$this->setupTemplatingFilters();
$this->setupGeneratorQueue();
}
private function loadServicesFromConfig()
{
$builder = $this->getContainerBuilder();
$config = $this->loadFromFile(__DIR__ . '/apigen.services.neon');
$this->compiler->parseServices($builder, $config);
}
private function setupTemplating()
{
$builder = $this->getContainerBuilder();
$builder->addDefinition($this->prefix('latteFactory'))
->setClass('Latte\Engine')
->addSetup('setTempDirectory', [$builder->expand('%tempDir%/cache/latte')]);
}
private function setupConsole()
{
$builder = $this->getContainerBuilder();
$application = $builder->getDefinition($builder->getByType('ApiGen\Console\Application'));
foreach (array_keys($builder->findByTag(self::TAG_CONSOLE_COMMAND)) as $serviceName) {
$className = $builder->getDefinition($serviceName)->getClass();
if ( ! $this->isPhar() && $className === 'ApiGen\Command\SelfUpdateCommand') {
continue;
}
$application->addSetup('add', ['@' . $serviceName]);
}
}
/**
* @return bool
*/
private function isPhar()
{
return substr(__FILE__, 0, 5) === 'phar:';
}
private function setupTemplatingFilters()
{
$builder = $this->getContainerBuilder();
$latteFactory = $builder->getDefinition($builder->getByType('Latte\Engine'));
foreach (array_keys($builder->findByTag(self::TAG_LATTE_FILTER)) as $serviceName) {
$latteFactory->addSetup('addFilter', [NULL, ['@' . $serviceName, 'loader']]);
}
}
private function setupGeneratorQueue()
{
$builder = $this->getContainerBuilder();
$generator = $builder->getDefinition($builder->getByType('ApiGen\Generator\GeneratorQueue'));
foreach (array_keys($builder->findByTag(self::TAG_TEMPLATE_GENERATOR)) as $serviceName) {
$generator->addSetup('addToQueue', ['@' . $serviceName]);
}
}
}
|