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


PHP FileGenerator::setUses方法代码示例

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


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

示例1: generate

 public function generate()
 {
     $modelBuilder = $this->controller->getModelBuilder();
     $className = $modelBuilder->getName() . 'Controller';
     $class = new ClassGenerator();
     $class->setName($className);
     $class->setExtendedClass('CrudController');
     $param = new ParameterGenerator();
     $param->setName('fb')->setType('FormBuilder');
     $body = $this->generateFormBuilderBody();
     $docblock = '@param FormBuilder $fb';
     $class->addMethod('buildForm', array($param), MethodGenerator::FLAG_PUBLIC, $body, $docblock);
     $param = new ParameterGenerator();
     $param->setName('mb')->setType('ModelBuilder');
     $body = '';
     $docblock = '@param ModelBuilder $mb';
     $class->addMethod('buildModel', array($param), MethodGenerator::FLAG_PUBLIC, $body, $docblock);
     $param = new ParameterGenerator();
     $param->setName('ob')->setType('OverviewBuilder');
     $body = '';
     $docblock = '@param OverviewBuilder $ob';
     $class->addMethod('buildOverview', array($param), MethodGenerator::FLAG_PUBLIC, $body, $docblock);
     $this->generator->setClass($class);
     $this->generator->setUses(array('Boyhagemann\\Crud\\CrudController', 'Boyhagemann\\Form\\FormBuilder', 'Boyhagemann\\Model\\ModelBuilder', 'Boyhagemann\\Overview\\OverviewBuilder'));
     return $this->generator->generate();
 }
开发者ID:boyhagemann,项目名称:framework,代码行数:26,代码来源:ControllerGenerator.php

示例2: addToConfigObjects

 private function addToConfigObjects($objectName, $objectHandlerName, $objectHandlerFactoryName)
 {
     $conf = (include $this->confPath);
     $fileGenerator = FileGenerator::fromReflectedFileName($this->confPath);
     $conf['service_manager']['factories'][$objectHandlerName] = $objectHandlerFactoryName;
     $conf['tactician']['handler-map'][$objectName] = $objectHandlerName;
     $body = sprintf('return %s;', var_export($conf, TRUE));
     $newFile = new FileGenerator();
     $newFile->setUses($fileGenerator->getUses());
     $newFile->setBody($body);
     file_put_contents($this->confPath, $newFile->generate());
 }
开发者ID:Code-Mine-Development,项目名称:CommandQueryGenerator,代码行数:12,代码来源:ConfigService.php

示例3: testSetUsesWithGetUses

 public function testSetUsesWithGetUses()
 {
     $file = new FileGenerator();
     $uses = array('Your\\Bar', 'My\\Baz', array('use' => 'Another\\Baz', 'as' => 'Baz2'));
     $file->setUses($uses);
     $file->setUses($file->getUses());
     $generated = $file->generate();
     $this->assertContains('use My\\Baz;', $generated);
     $this->assertContains('use Your\\Bar;', $generated);
     $this->assertContains('use Another\\Baz as Baz2;', $generated);
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:11,代码来源:FileGeneratorTest.php


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