本文整理匯總了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);
}