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


PHP ContainerBuilder::addDependency方法代码示例

本文整理汇总了PHP中Nette\DI\ContainerBuilder::addDependency方法的典型用法代码示例。如果您正苦于以下问题:PHP ContainerBuilder::addDependency方法的具体用法?PHP ContainerBuilder::addDependency怎么用?PHP ContainerBuilder::addDependency使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nette\DI\ContainerBuilder的用法示例。


在下文中一共展示了ContainerBuilder::addDependency方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generateCode

 public function generateCode($className, $parentName)
 {
     foreach ($this->extensions as $extension) {
         $extension->beforeCompile();
         $this->container->addDependency(Nette\Reflection\ClassType::from($extension)->getFileName());
     }
     $classes[] = $class = $this->container->generateClass($parentName);
     $class->setName($className)->addMethod('initialize');
     foreach ($this->extensions as $extension) {
         $extension->afterCompile($class);
     }
     $defs = $this->container->getDefinitions();
     ksort($defs);
     $list = array_keys($defs);
     foreach (array_reverse($defs, TRUE) as $name => $def) {
         if ($def->class === 'Nette\\DI\\NestedAccessor' && ($found = preg_grep('#^' . $name . '\\.#i', $list))) {
             $list = array_diff($list, $found);
             $def->class = $className . '_' . preg_replace('#\\W+#', '_', $name);
             $class->documents = preg_replace("#\\S+(?= \\\${$name}\\z)#", $def->class, $class->documents);
             $classes[] = $accessor = new Nette\Utils\PhpGenerator\ClassType($def->class);
             foreach ($found as $item) {
                 if ($defs[$item]->internal) {
                     continue;
                 }
                 $short = substr($item, strlen($name) + 1);
                 $accessor->addDocument($defs[$item]->shared ? "@property {$defs[$item]->class} \${$short}" : "@method {$defs[$item]->class} create" . ucfirst("{$short}()"));
             }
         }
     }
     return implode("\n\n\n", $classes);
 }
开发者ID:genextwebs,项目名称:dropbox-sample,代码行数:31,代码来源:Compiler.php

示例2: generateCode

 public function generateCode($className, $parentName)
 {
     foreach ($this->extensions as $extension) {
         $extension->beforeCompile();
         $this->builder->addDependency(Nette\Reflection\ClassType::from($extension)->getFileName());
     }
     $classes = $this->builder->generateClasses($className, $parentName);
     $classes[0]->addMethod('initialize');
     foreach ($this->extensions as $extension) {
         $extension->afterCompile($classes[0]);
     }
     return implode("\n\n\n", $classes);
 }
开发者ID:cujan,项目名称:atlashornin,代码行数:13,代码来源:Compiler.php


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