本文整理汇总了PHP中Nette\DI\Compiler::getExtensions方法的典型用法代码示例。如果您正苦于以下问题:PHP Compiler::getExtensions方法的具体用法?PHP Compiler::getExtensions怎么用?PHP Compiler::getExtensions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\DI\Compiler
的用法示例。
在下文中一共展示了Compiler::getExtensions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setCompiler
public function setCompiler(Nette\DI\Compiler $compiler, $name) : self
{
$application = current($compiler->getExtensions(Nette\Bridges\ApplicationDI\ApplicationExtension::class));
if ($application instanceof Nette\Bridges\ApplicationDI\ApplicationExtension) {
$application->defaults['errorPresenter'] = FALSE;
$application->defaults['scanDirs'] = FALSE;
$application->defaults['mapping'] = ['*' => 'Ytnuk\\*\\*'];
}
$session = current($compiler->getExtensions(Nette\Bridges\HttpDI\SessionExtension::class));
if ($session instanceof Nette\Bridges\HttpDI\SessionExtension) {
$session->defaults['debugger'] = $this->debugMode;
}
$http = current($compiler->getExtensions(Nette\Bridges\HttpDI\HttpExtension::class));
if ($http instanceof Nette\Bridges\HttpDI\HttpExtension) {
$http->defaults['headers']['X-Powered-By'] = __NAMESPACE__;
$contentSecurityPolicy = ['default-src' => '\'self\'', 'form-action' => '\'self\'', 'img-src' => '\'self\' data:'];
if ($this->debugMode) {
$contentSecurityPolicy += ['script-src' => '\'self\' \'unsafe-inline\' \'unsafe-eval\'', 'style-src' => '\'self\' \'unsafe-inline\''];
}
$http->defaults['headers']['Content-Security-Policy'] = implode(';', array_map(function (string $key, string $value) {
return implode(' ', [$key, $value]);
}, array_keys($contentSecurityPolicy), array_values($contentSecurityPolicy)));
}
$di = current($compiler->getExtensions(Nette\DI\Extensions\DIExtension::class));
if ($di instanceof Nette\DI\Extensions\DIExtension) {
$di->defaults['debugger'] = $this->debugMode;
}
return parent::setCompiler($compiler, $name);
}