當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FileGenerator::getFilename方法代碼示例

本文整理匯總了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;
 }
開發者ID:CHRISTOPHERVANDOMME,項目名稱:zf2complet,代碼行數:20,代碼來源:FileGeneratorRegistry.php

示例2: writeClass

 /**
  * @inheritDoc
  */
 public function writeClass(FileGenerator $fileGenerator)
 {
     file_put_contents($fileGenerator->getFilename(), $this->replaceNamespace($fileGenerator));
 }
開發者ID:proophsoftware,項目名稱:prooph-cli,代碼行數:7,代碼來源:AddEventToAggregate.php

示例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;
 }
開發者ID:progrupa,項目名稱:MailjetBundle,代碼行數:28,代碼來源:ApiController.php

示例4: writeClass

 /**
  * @inheritDoc
  */
 public function writeClass(FileGenerator $fileGenerator)
 {
     file_put_contents($fileGenerator->getFilename(), $fileGenerator->generate());
 }
開發者ID:sandrokeil,項目名稱:prooph-cli,代碼行數:7,代碼來源:AddEventToAggregate.php

示例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;
 }
開發者ID:baleen,項目名稱:cli,代碼行數:23,代碼來源:CreateHandler.php


注:本文中的Zend\Code\Generator\FileGenerator::getFilename方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。