本文整理汇总了PHP中Zend\Code\Generator\FileGenerator::getFilename方法的典型用法代码示例。如果您正苦于以下问题:PHP FileGenerator::getFilename方法的具体用法?PHP FileGenerator::getFilename怎么用?PHP FileGenerator::getFilename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Code\Generator\FileGenerator
的用法示例。
在下文中一共展示了FileGenerator::getFilename方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerFileCodeGenerator
/**
* Registry for the Zend\Code package.
*
* @param FileGenerator $fileCodeGenerator
* @param string $fileName
* @throws RuntimeException
*/
public static function registerFileCodeGenerator(FileGenerator $fileCodeGenerator, $fileName = null)
{
if ($fileName === null) {
$fileName = $fileCodeGenerator->getFilename();
}
if ($fileName == '') {
throw new RuntimeException('FileName does not exist.');
}
// cannot use realpath since the file might not exist, but we do need to have the index
// in the same DIRECTORY_SEPARATOR that realpath would use:
$fileName = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $fileName);
static::$fileCodeGenerators[$fileName] = $fileCodeGenerator;
}
示例2: writeClass
/**
* @inheritDoc
*/
public function writeClass(FileGenerator $fileGenerator)
{
file_put_contents($fileGenerator->getFilename(), $this->replaceNamespace($fileGenerator));
}
示例3: 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;
}
示例4: writeClass
/**
* @inheritDoc
*/
public function writeClass(FileGenerator $fileGenerator)
{
file_put_contents($fileGenerator->getFilename(), $fileGenerator->generate());
}
示例5: writeClass
/**
* Function writeClass.
*
* @param ClassGenerator $class
* @param Filesystem $filesystem
* @param $destinationDir
*
* @return string|false
*
* @throws CliException
*/
protected function writeClass(ClassGenerator $class, Filesystem $filesystem, $destinationDir)
{
$className = $class->getName();
$file = new FileGenerator(['fileName' => $className . '.php', 'classes' => [$class]]);
$contents = $file->generate();
$relativePath = $destinationDir . DIRECTORY_SEPARATOR . $file->getFilename();
if ($filesystem->has($relativePath)) {
throw new CliException(sprintf('Could not generate migration. File already exists: %s', $relativePath));
}
$result = $filesystem->write($relativePath, $contents);
return $result ? $relativePath : false;
}