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