本文整理匯總了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);
}
}
示例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);
}
}
示例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;
}
示例4: addTrait
/**
* @param string
* @return ClassType
*/
public function addTrait(string $name) : ClassType
{
return $this->addNamespace(Helpers::extractNamespace($name))->addTrait(Helpers::extractShortName($name));
}
示例5: addTrait
/**
* @param string
* @return ClassType
*/
public function addTrait($name)
{
return $this->addNamespace(Helpers::extractNamespace($name))->addTrait(Helpers::extractShortName($name));
}