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