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


PHP Helpers::extractShortName方法代碼示例

本文整理匯總了PHP中Nette\PhpGenerator\Helpers::extractShortName方法的典型用法代碼示例。如果您正苦於以下問題:PHP Helpers::extractShortName方法的具體用法?PHP Helpers::extractShortName怎麽用?PHP Helpers::extractShortName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Nette\PhpGenerator\Helpers的用法示例。


在下文中一共展示了Helpers::extractShortName方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: generate

 /**
  * @param Database $database
  */
 public function generate(Database $database)
 {
     foreach ($database->getTables() as $table) {
         // Create namespace and inner class
         $namespace = new PhpNamespace($this->resolver->resolveRepositoryNamespace($table));
         $class = $namespace->addClass($this->resolver->resolveRepositoryName($table));
         // Detect extends class
         if (($extends = $this->config->get('repository.extends')) !== NULL) {
             $namespace->addUse($extends);
             $class->setExtends($extends);
         }
         // Save file
         $this->generateFile($this->resolver->resolveRepositoryFilename($table), (string) $namespace);
     }
     // Generate abstract base class
     if ($this->config->get('repository.extends') !== NULL) {
         // Create abstract class
         $namespace = new PhpNamespace($this->config->get('repository.namespace'));
         $class = $namespace->addClass(Helpers::extractShortName($this->config->get('repository.extends')));
         $class->setAbstract(TRUE);
         // Add extends from ORM/Repository
         $extends = $this->config->get('nextras.orm.class.repository');
         $namespace->addUse($extends);
         $class->setExtends($extends);
         // Save file
         $this->generateFile($this->resolver->resolveFilename(Helpers::extractShortName($this->config->get('repository.extends')), $this->config->get('repository.folder')), (string) $namespace);
     }
 }
開發者ID:minetro,項目名稱:normgen,代碼行數:31,代碼來源:RepositoryGenerator.php

示例2: generate

 /**
  * @param Database $database
  */
 public function generate(Database $database)
 {
     foreach ($database->getTables() as $table) {
         // Create namespace and inner class
         $namespace = new PhpNamespace($this->resolver->resolveEntityNamespace($table));
         $class = $namespace->addClass($this->resolver->resolveEntityName($table));
         // Detect extends class
         if (($extends = $this->config->get('entity.extends')) === NULL) {
             $extends = $this->config->get('nextras.orm.class.entity');
         }
         // Add namespace and extends class
         $namespace->addUse($extends);
         $class->setExtends($extends);
         // Add table columns
         foreach ($table->getColumns() as $column) {
             if ($this->config->get('generator.entity.exclude.primary')) {
                 if ($column->isPrimary()) {
                     continue;
                 }
             }
             foreach ($this->decorators as $decorator) {
                 $decorator->doDecorate($column, $class, $namespace);
             }
         }
         // Save file
         $this->generateFile($this->resolver->resolveEntityFilename($table), (string) $namespace);
     }
     // Generate abstract base class
     if ($this->config->get('entity.extends') !== NULL) {
         // Create abstract class
         $namespace = new PhpNamespace($this->config->get('entity.namespace'));
         $class = $namespace->addClass(Helpers::extractShortName($this->config->get('entity.extends')));
         $class->setAbstract(TRUE);
         // Add extends from ORM/Entity
         $extends = $this->config->get('nextras.orm.class.entity');
         $namespace->addUse($extends);
         $class->setExtends($extends);
         // Save file
         $this->generateFile($this->resolver->resolveFilename(Helpers::extractShortName($this->config->get('entity.extends')), $this->config->get('entity.folder')), (string) $namespace);
     }
 }
開發者ID:minetro,項目名稱:normgen,代碼行數:44,代碼來源:EntityGenerator.php

示例3: addUse

 /**
  * @param  string
  * @param  string
  * @param  string
  * @throws InvalidStateException
  * @return self
  */
 public function addUse(string $name, string $alias = NULL, string &$aliasOut = NULL) : self
 {
     $name = ltrim($name, '\\');
     if ($alias === NULL && $this->name === Helpers::extractNamespace($name)) {
         $alias = Helpers::extractShortName($name);
     }
     if ($alias === NULL) {
         $path = explode('\\', $name);
         $counter = NULL;
         do {
             if (empty($path)) {
                 $counter++;
             } else {
                 $alias = array_pop($path) . $alias;
             }
         } while (isset($this->uses[$alias . $counter]) && $this->uses[$alias . $counter] !== $name);
         $alias .= $counter;
     } elseif (isset($this->uses[$alias]) && $this->uses[$alias] !== $name) {
         throw new InvalidStateException("Alias '{$alias}' used already for '{$this->uses[$alias]}', cannot use for '{$name}'.");
     }
     $aliasOut = $alias;
     $this->uses[$alias] = $name;
     return $this;
 }
開發者ID:kukulich,項目名稱:php-generator,代碼行數:31,代碼來源:PhpNamespace.php

示例4: addTrait

 /**
  * @param  string
  * @return ClassType
  */
 public function addTrait(string $name) : ClassType
 {
     return $this->addNamespace(Helpers::extractNamespace($name))->addTrait(Helpers::extractShortName($name));
 }
開發者ID:kukulich,項目名稱:php-generator,代碼行數:8,代碼來源:PhpFile.php

示例5: addTrait

 /**
  * @param  string
  * @return ClassType
  */
 public function addTrait($name)
 {
     return $this->addNamespace(Helpers::extractNamespace($name))->addTrait(Helpers::extractShortName($name));
 }
開發者ID:JanTvrdik,項目名稱:nette-php-generator,代碼行數:8,代碼來源:PhpFile.php


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