當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。