当前位置: 首页>>代码示例>>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;未经允许,请勿转载。