本文整理汇总了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();
}
示例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());
}
示例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);
}