當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Compiler::getContainerBuilder方法代碼示例

本文整理匯總了PHP中Nette\DI\Compiler::getContainerBuilder方法的典型用法代碼示例。如果您正苦於以下問題:PHP Compiler::getContainerBuilder方法的具體用法?PHP Compiler::getContainerBuilder怎麽用?PHP Compiler::getContainerBuilder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Nette\DI\Compiler的用法示例。


在下文中一共展示了Compiler::getContainerBuilder方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: loadFromFile

 /**
  * Reads configuration from file.
  * @param  string  file name
  * @return array
  */
 public function loadFromFile($file)
 {
     $loader = new Config\Loader();
     $res = $loader->load($file);
     $container = $this->compiler->getContainerBuilder();
     foreach ($loader->getDependencies() as $file) {
         $container->addDependency($file);
     }
     return $res;
 }
開發者ID:petrparolek,項目名稱:web_cms,代碼行數:15,代碼來源:CompilerExtension.php

示例2: generate

 /**
  * @return array of (code, file[])
  */
 protected function generate($class, $generator)
 {
     $compiler = new Compiler();
     $compiler->getContainerBuilder()->setClassName($class);
     $code = call_user_func_array($generator, [&$compiler]);
     $code = $code ?: implode("\n\n\n", $compiler->compile());
     $files = $compiler->getDependencies();
     $files = call_user_func($this->filter, $files);
     $files = array_combine($files, $files);
     return array("<?php\n{$code}", serialize(@array_map('filemtime', $files)));
 }
開發者ID:arachne,項目名稱:bootstrap,代碼行數:14,代碼來源:ContainerLoader.php

示例3: getContainerBuilder

 /**
  * @return ContainerBuilder
  */
 public function getContainerBuilder()
 {
     return $this->compiler->getContainerBuilder();
 }
開發者ID:Northys,項目名稱:di,代碼行數:7,代碼來源:CompilerExtension.php

示例4: generateContainer

 /**
  * @return string
  * @internal
  */
 public function generateContainer(DI\Compiler $compiler)
 {
     $loader = $this->createLoader();
     $compiler->addConfig(['parameters' => $this->parameters]);
     $fileInfo = [];
     foreach ($this->files as $info) {
         if (is_scalar($info[0])) {
             $fileInfo[] = "// source: {$info['0']} {$info['1']}";
             $info[0] = $loader->load($info[0], $info[1]);
         }
         $compiler->addConfig($this->fixCompatibility($info[0]));
     }
     $compiler->addDependencies($loader->getDependencies());
     $builder = $compiler->getContainerBuilder();
     $builder->addExcludedClasses($this->autowireExcludedClasses);
     foreach ($this->defaultExtensions as $name => $extension) {
         list($class, $args) = is_string($extension) ? [$extension, []] : $extension;
         if (class_exists($class)) {
             $args = DI\Helpers::expand($args, $this->parameters, TRUE);
             $compiler->addExtension($name, (new \ReflectionClass($class))->newInstanceArgs($args));
         }
     }
     $this->onCompile($this, $compiler);
     $classes = $compiler->compile();
     if (!empty($builder->parameters['container']['parent'])) {
         $classes[0]->setExtends($builder->parameters['container']['parent']);
     }
     return implode("\n", $fileInfo) . "\n\n" . implode("\n\n\n", $classes) . (($tmp = $builder->parameters['container']['class']) ? "\nclass {$tmp} extends {$builder->getClassName()} {}\n" : '');
 }
開發者ID:pt24,項目名稱:bootstrap,代碼行數:33,代碼來源:Configurator.php

示例5: generate

 /**
  * @return array of (code, file[])
  */
 protected function generate($class, $generator)
 {
     $compiler = new Compiler();
     $compiler->getContainerBuilder()->setClassName($class);
     $code = call_user_func_array($generator, array(&$compiler));
     $code = $code ?: implode("\n\n\n", $compiler->compile());
     $files = $compiler->getDependencies();
     $files = $files ? array_combine($files, $files) : array();
     // workaround for PHP 5.3 array_combine
     return array("<?php\n{$code}", serialize(@array_map('filemtime', $files)));
 }
開發者ID:knedle,項目名稱:twitter-nette-skeleton,代碼行數:14,代碼來源:ContainerLoader.php

示例6: generateContainer

 /**
  * @param Compiler $compiler
  * @return string
  */
 public function generateContainer(Compiler $compiler)
 {
     // Load configs
     $loader = new Loader();
     $compiler->addConfig(['parameters' => $this->parameters]);
     foreach ($this->configs as $config) {
         $compiler->addConfig($loader->load($config));
     }
     $compiler->addDependencies($loader->getDependencies());
     // Exclude classes
     $builder = $compiler->getContainerBuilder();
     $builder->addExcludedClasses($this->excludedClasses);
     // Fire events
     foreach ($this->onCompile as $cb) {
         call_user_func_array($cb, [$compiler]);
     }
     // Compile container
     $classes = $compiler->compile();
     $classes[0]->setExtends(PiDiContainer::class);
     return implode("\n", []) . "\n\n" . implode("\n\n\n", $classes);
 }
開發者ID:phalette,項目名稱:pidic,代碼行數:25,代碼來源:Configurator.php


注:本文中的Nette\DI\Compiler::getContainerBuilder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。