当前位置: 首页>>代码示例>>PHP>>正文


PHP Compiler::getExtensions方法代码示例

本文整理汇总了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);
 }
开发者ID:ytnuk,项目名称:application,代码行数:29,代码来源:Extension.php


注:本文中的Nette\DI\Compiler::getExtensions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。