本文整理汇总了PHP中Doctrine\Common\Persistence\ManagerRegistry::getAliasNamespace方法的典型用法代码示例。如果您正苦于以下问题:PHP ManagerRegistry::getAliasNamespace方法的具体用法?PHP ManagerRegistry::getAliasNamespace怎么用?PHP ManagerRegistry::getAliasNamespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Persistence\ManagerRegistry
的用法示例。
在下文中一共展示了ManagerRegistry::getAliasNamespace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEntityClass
/**
* Gets a real class name for an entity.
*
* @param object|string $entityOrClass An entity object, entity class name or entity proxy class name
*
* @return string
*/
public function getEntityClass($entityOrClass)
{
if (is_object($entityOrClass)) {
return ClassUtils::getClass($entityOrClass);
}
if (strpos($entityOrClass, ':') !== false) {
list($namespaceAlias, $simpleClassName) = explode(':', $entityOrClass, 2);
return $this->registry->getAliasNamespace($namespaceAlias) . '\\' . $simpleClassName;
}
return ClassUtils::getRealClass($entityOrClass);
}
示例2: getEntityClass
/**
* Gets the full class name for the given entity
*
* @param string $entityName The name of the entity. Can be bundle:entity or full class name
* @return string The full class name
* @throws \InvalidArgumentException
*/
public function getEntityClass($entityName)
{
$split = explode(':', $entityName);
if (count($split) <= 1) {
// The given entity name is not in bundle:entity format. Suppose that it is the full class name
return $entityName;
} elseif (count($split) > 2) {
throw new \InvalidArgumentException(sprintf('Incorrect entity name: %s. Expected the full class name or bundle:entity.', $entityName));
}
return $this->doctrine->getAliasNamespace($split[0]) . '\\' . $split[1];
}
示例3: getRepository
/**
* Returns custom repository if one specified otherwise returns a basic repository.
*
* {@inheritdoc}
*/
public function getRepository($entityName)
{
$realEntityName = $entityName;
if (strpos($entityName, ':') !== false) {
list($namespaceAlias, $simpleClassName) = explode(':', $entityName);
$realEntityName = $this->managerRegistry->getAliasNamespace($namespaceAlias) . '\\' . $simpleClassName;
}
if (isset($this->entities[$realEntityName])) {
$realEntityName = $this->entities[$realEntityName];
}
return $this->repositoryManager->getRepository($realEntityName);
}