本文整理汇总了PHP中Zend\Code\Generator\FileGenerator::setDocBlock方法的典型用法代码示例。如果您正苦于以下问题:PHP FileGenerator::setDocBlock方法的具体用法?PHP FileGenerator::setDocBlock怎么用?PHP FileGenerator::setDocBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Code\Generator\FileGenerator
的用法示例。
在下文中一共展示了FileGenerator::setDocBlock方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
*
* @param DTDDocument $document
* @param string $outputDirectory
* @param string $namespace
* @param string $parentClass
*/
public function generate(DTDDocument $document, $outputDirectory, $namespace, $parentClass)
{
if (!file_exists($outputDirectory)) {
mkdir($outputDirectory, 0777, true);
}
$name = ucfirst($document->getFileInfo()->getBasename('.dtd'));
$filename = sprintf("%s/%s.php", $outputDirectory, $name);
$classGenerator = new ClassGenerator($name, $namespace, null, $parentClass);
$fileGenerator = new FileGenerator();
$fileGenerator->setClass($classGenerator);
$fileDocblock = new DocBlockGenerator(sprintf("%s %s", str_replace("\\", " ", $namespace), $name));
$fileDocblock->setTag(new Tag("author", "Generator"));
$fileDocblock->setTag(new Tag("licence", "LGPL"));
$fileGenerator->setDocBlock($fileDocblock);
file_put_contents($filename, $fileGenerator->generate());
}
示例2: execute
/**
* (non-PHPdoc)
*
* @see \Symfony\Component\Console\Command\Command::execute()
*/
public function execute(InputInterface $input, OutputInterface $output)
{
$document = $this->getDocument($input->getArgument('document'));
$directory = $input->getArgument('output');
$namespace = $input->getArgument('namespace');
$parentClass = $input->getArgument('parentClass');
if (!file_exists($directory)) {
mkdir($directory, 0777, true);
}
$name = ucfirst($document->getFileInfo()->getBasename('.dtd'));
$output->writeln("Generating Document " . $name);
$filename = sprintf("%s/%s.php", $directory, $name);
$classGenerator = new ClassGenerator($name, $namespace, null, $parentClass);
$fileGenerator = new FileGenerator();
$fileGenerator->setClass($classGenerator);
$fileDocblock = new DocBlockGenerator(sprintf("%s %s", str_replace("\\", " ", $namespace), $name));
$fileDocblock->setTag(new Tag("author", "Generator"));
$fileDocblock->setTag(new Tag("licence", "LGPL"));
$fileGenerator->setDocBlock($fileDocblock);
file_put_contents($filename, $fileGenerator->generate());
}
示例3: updateModuleWithClassmapAutoloader
/**
* Update module class with class map autoloading
*
* @return bool
* @throws \Zend\Code\Generator\Exception
*/
public function updateModuleWithClassmapAutoloader()
{
// get needed options to shorten code
$path = realpath($this->requestOptions->getPath());
$directory = $this->requestOptions->getDirectory();
$destination = $this->requestOptions->getDestination();
$moduleFile = $directory . '/Module.php';
$moduleClass = str_replace($path . '/module/', '', $directory) . '\\Module';
$moduleName = str_replace($path . '/module/', '', $directory);
// check for module file
if (!file_exists($moduleFile)) {
return false;
}
// get file and class reflection
$fileReflection = new FileReflection($moduleFile, true);
$classReflection = $fileReflection->getClass($moduleClass);
// setup class generator with reflected class
$code = ClassGenerator::fromReflection($classReflection);
// check for action method
if ($code->hasMethod('getAutoloaderConfig')) {
$code->removeMethod('getAutoloaderConfig');
}
// add getAutoloaderConfig method with class map
$code->addMethodFromGenerator($this->generateGetAutoloaderConfigMethod($destination, $moduleName));
// create file with file generator
$file = new FileGenerator();
$file->setClass($code);
// add optional doc block
if ($this->flagCreateApiDocs) {
$file->setDocBlock(new DocBlockGenerator('This file was generated by FrilleZFTool.', null, array($this->generatePackageTag($moduleName), $this->generateSeeTag())));
}
// create file with file generator
$file = new FileGenerator();
$file->setClass($code);
// add optional doc block
if ($this->flagCreateApiDocs) {
$file->setDocBlock(new DocBlockGenerator('This file was generated by FrilleZFTool.', null, array($this->generatePackageTag($moduleName), $this->generateSeeTag())));
}
// write module class
if (!file_put_contents($moduleFile, $file->generate())) {
return false;
}
return true;
}
示例4: createModuleConfig
/**
* creates module config files
*
* @return string returns config path
*/
protected function createModuleConfig()
{
$config = array();
$configPath = $this->moduleRoot() . '/config/module.config.php';
if (file_exists($configPath)) {
$config = (require $configPath);
}
$moduleConfig = new FileGenerator();
$moduleConfig->setDocBlock($this->getFileDocBlock());
$moduleConfig->getDocBlock()->setShortDescription(sprintf($this->codeLibrary()->get('module.standardConfigDescription'), $this->params->getParam('moduleName')));
$moduleConfig->setBody('return ' . var_export($config, true) . ';');
$this->console('writing module config file');
file_put_contents($this->moduleRoot() . '/config/module.config.php', $moduleConfig->generate());
return $configPath;
}
示例5: generateModelFromMetadata
/**
* Generate Madel class from metadata
*
* @param stdClass $metadata
* @return Generator\ClassGenerator|null
*/
protected function generateModelFromMetadata($metadata)
{
$console = $this->getServiceLocator()->get('console');
$name = $metadata->Name;
$ucName = ucfirst($name);
// Create Api Class
$class = new Generator\ClassGenerator($ucName, 'Mailjet\\Model');
$class->setImplementedInterfaces(array('ModelInterface'))->setDocBlock(new Generator\DocBlockGenerator($class->getName() . ' Model', $metadata->Description, array()));
$this->addProperties($class, $metadata->Properties);
// Create and Write Api Class File
$file = new Generator\FileGenerator();
$file->setClass($class);
$file->setDocBlock(new Generator\DocBlockGenerator('MailJet Model', self::LICENSE));
$file->setFilename(dirname(__DIR__) . '/Model/' . $class->getName() . '.php');
if (file_put_contents($file->getFilename(), $file->generate())) {
$console->writeLine(sprintf("The Model '%s' has been created.", $class->getName()), Color::GREEN);
return $class;
} else {
$console->writeLine(sprintf("There was an error during '%s' Model creation.", $class->getName()), Color::RED);
}
return $class;
}
示例6: writeModuleConfig
/**
* writes module config
*
* @param array $config
* @param string $path
*/
protected function writeModuleConfig(array $config, $path)
{
$moduleName = $this->params->getParam('moduleName');
$generatorConfig = new FileGenerator();
$docBlock = new DocBlockGenerator();
$docBlock->setTag(new GenericTag('author', $this->params->getParam('author')));
$docBlock->setTag(new GenericTag('project', $this->params->getParam('project')));
$docBlock->setTag(new GenericTag('license', $this->params->getParam('license')));
$docBlock->setTag(new GenericTag('copyright', $this->params->getParam('copyright')));
$docBlock->setShortDescription(sprintf($this->codeLibrary()->get('module.generatedConfigDescription'), $moduleName));
$generatorConfig->setDocBlock($docBlock);
$configString = var_export($config, true);
$configString = str_replace("'/../view'", '__DIR__ . \'/../view\'', $configString);
$generatorConfig->setBody('return ' . $configString . ';');
file_put_contents($path, $generatorConfig->generate());
}