本文整理汇总了PHP中Doctrine\Common\Util\ClassUtils::getRealClass方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassUtils::getRealClass方法的具体用法?PHP ClassUtils::getRealClass怎么用?PHP ClassUtils::getRealClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Util\ClassUtils
的用法示例。
在下文中一共展示了ClassUtils::getRealClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: supports
/**
* {@inheritdoc}
*/
public function supports(PuliResource $resource)
{
if (false === $resource instanceof CmfResource) {
return false;
}
return $this->metadataFactory->hasMetadataFor(ClassUtils::getRealClass($resource->getPayloadType()));
}
示例2: boot
/**
* {@inheritDoc}
*/
public function boot()
{
// Register an autoloader for proxies to avoid issues when unserializing them
// when the ORM is used.
if ($this->container->hasParameter('doctrine.orm.proxy_namespace')) {
$namespace = $this->container->getParameter('doctrine.orm.proxy_namespace');
$dir = $this->container->getParameter('doctrine.orm.proxy_dir');
$proxyGenerator = null;
if ($this->container->getParameter('doctrine.orm.auto_generate_proxy_classes')) {
// See https://github.com/symfony/symfony/pull/3419 for usage of references
$container =& $this->container;
$proxyGenerator = function ($proxyDir, $proxyNamespace, $class) use(&$container) {
$originalClassName = ClassUtils::getRealClass($class);
/** @var $registry Registry */
$registry = $container->get('doctrine');
// Tries to auto-generate the proxy file
/** @var $em \Doctrine\ORM\EntityManager */
foreach ($registry->getManagers() as $em) {
if (!$em->getConfiguration()->getAutoGenerateProxyClasses()) {
continue;
}
$metadataFactory = $em->getMetadataFactory();
if ($metadataFactory->isTransient($originalClassName)) {
continue;
}
$classMetadata = $metadataFactory->getMetadataFor($originalClassName);
$em->getProxyFactory()->generateProxyClasses(array($classMetadata));
clearstatcache(true, Autoloader::resolveFile($proxyDir, $proxyNamespace, $class));
break;
}
};
}
$this->autoloader = Autoloader::register($dir, $namespace, $proxyGenerator);
}
}
示例3: getRealClass
public static function getRealClass($class)
{
if (class_exists('Doctrine\\Common\\Util\\ClassUtils')) {
$class = DoctrineClassUtils::getRealClass($class);
}
return $class;
}
示例4: resultatsLinkTerritoire
public function resultatsLinkTerritoire($territoire)
{
switch (ClassUtils::getRealClass(get_class($territoire))) {
case 'AppBundle\\Domain\\Territoire\\Entity\\Territoire\\CirconscriptionEuropeenne':
$route = 'resultat_circo_europeenne';
$parameters = array('code' => $territoire->getCode(), 'nom' => $this->slugify->slugify($territoire->getNom()));
break;
case 'AppBundle\\Domain\\Territoire\\Entity\\Territoire\\Commune':
$route = 'resultat_commune';
$parameters = array('departement' => $territoire->getDepartement()->getCode(), 'code' => $territoire->getCode(), 'nom' => $this->slugify->slugify($territoire->getNom()));
break;
case 'AppBundle\\Domain\\Territoire\\Entity\\Territoire\\Departement':
$route = 'resultat_departement';
$parameters = array('code' => $territoire->getCode(), 'nom' => $this->slugify->slugify($territoire->getNom()));
break;
case 'AppBundle\\Domain\\Territoire\\Entity\\Territoire\\Pays':
$route = 'resultat_france';
$parameters = array();
break;
case 'AppBundle\\Domain\\Territoire\\Entity\\Territoire\\Region':
$route = 'resultat_region';
$parameters = array('code' => $territoire->getCode(), 'nom' => $this->slugify->slugify($territoire->getNom()));
break;
}
if (isset($route, $parameters)) {
return $this->router->generate($route, $parameters);
}
return '';
}
示例5: canonicalName
/**
* {@inheritDoc}
*
* use getRealClass if className names a doctrine proxy class.
*/
public function canonicalName($className)
{
$refl = new \ReflectionClass($className);
if (in_array('Doctrine\\Common\\Persistence\\Proxy', $refl->getInterfaceNames())) {
$className = \Doctrine\Common\Util\ClassUtils::getRealClass($className);
}
return $className;
}
示例6: getOwnerType
/**
* @param $entity
* @return string
*/
public function getOwnerType($entity)
{
$ownerClassName = ClassUtils::getRealClass(get_class($entity));
if (!$this->configProvider->hasConfig($ownerClassName)) {
return;
}
$config = $this->configProvider->getConfig($ownerClassName)->all();
return $config['owner_type'];
}
示例7: getRealClass
/**
* Get real class name of a reference that could be a proxy
*
* @param string $className Class name of reference object
*
* @return string
*/
protected function getRealClass($className)
{
if (Version::compare('2.2.0') <= 0) {
return ClassUtils::getRealClass($className);
}
if (substr($className, -5) === 'Proxy') {
return substr($className, 0, -5);
}
return $className;
}
示例8: getGedmoConfig
/**
*
* @param type $translatableClass
* @return type
*/
private function getGedmoConfig($translatableClass)
{
if (isset($this->gedmoConfig[$translatableClass])) {
return $this->gedmoConfig[$translatableClass];
}
$translatableClass = \Doctrine\Common\Util\ClassUtils::getRealClass($translatableClass);
$manager = $this->getManagerRegistry()->getManagerForClass($translatableClass);
$this->gedmoConfig[$translatableClass] = $this->gedmoTranslatableListener->getConfiguration($manager, $translatableClass);
return $this->gedmoConfig[$translatableClass];
}
示例9: 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);
}
示例10: markDirty
protected function markDirty(Identified $entity, array $data = [])
{
if (empty($entity->getId())) {
throw new InvalidArgumentException('Entity has no identifier');
}
$class = ClassUtils::getRealClass(get_class($entity));
$this->dirtyEntities[$class][$entity->getId()] = $data;
if ($this->autoFlush) {
$this->flushSync();
}
}
示例11: createClassIdentity
public function createClassIdentity($className)
{
$className = ClassUtils::getRealClass($className);
if (isset($this->classCache[$className])) {
return $this->classCache[$className];
}
if (null !== ($this->classCache[$className] = $this->classRepository->findOneByName($className))) {
return $this->classCache[$className];
}
$classClass = $this->classRepository->getClassName();
return $this->classCache[$className] = new $classClass($className);
}
示例12: getRealClass
/**
* Gets the real class name of a class name that could be a proxy.
*
* @param string|object $object
*
* @return string
*/
public static function getRealClass($object)
{
$class = is_object($object) ? get_class($object) : $object;
if (class_exists('Doctrine\\Common\\Util\\ClassUtils')) {
return DoctrineClassUtils::getRealClass($class);
}
// fallback in case doctrine common is not installed
if (false === ($pos = strrpos($class, '\\' . self::MARKER . '\\'))) {
return $class;
}
return substr($class, $pos + self::MARKER_LENGTH + 2);
}
示例13: handleCreateRequest
/**
* Create new
*
* @return Response
*/
public function handleCreateRequest()
{
$entity = $this->getManager()->createEntity();
$isProcessed = $this->processForm($entity);
if ($isProcessed) {
$entityClass = ClassUtils::getRealClass(get_class($entity));
$classMetadata = $this->getManager()->getObjectManager()->getClassMetadata($entityClass);
$view = $this->view($classMetadata->getIdentifierValues($entity), Codes::HTTP_CREATED);
} else {
$view = $this->view($this->getForm(), Codes::HTTP_BAD_REQUEST);
}
return $this->handleView($view);
}
示例14: getTranslatableFields
/**
*
* @param type $translationClass
* @return type
*/
protected function getTranslatableFields($translationClass)
{
$translationClass = \Doctrine\Common\Util\ClassUtils::getRealClass($translationClass);
$manager = $this->getManagerRegistry()->getManagerForClass($translationClass);
$metadataClass = $manager->getMetadataFactory()->getMetadataFor($translationClass);
$fields = array();
foreach ($metadataClass->fieldMappings as $fieldMapping) {
if (!in_array($fieldMapping['fieldName'], array('id', 'locale'))) {
$fields[] = $fieldMapping['fieldName'];
}
}
return $fields;
}
示例15: getRepository
/**
* @param EntityManagerInterface|EntityManager $entityManager
* @param string $entityName
* @return EntityRepository
*/
public function getRepository(EntityManagerInterface $entityManager, $entityName)
{
if (is_object($entityName)) {
$entityName = Doctrine\Common\Util\ClassUtils::getRealClass(get_class($entityName));
}
$entityName = ltrim($entityName, '\\');
if (isset($this->repositoryList[$emId = spl_object_hash($entityManager)][$entityName])) {
return $this->repositoryList[$emId][$entityName];
}
/** @var Doctrine\ORM\Mapping\ClassMetadata $metadata */
$metadata = $entityManager->getClassMetadata($entityName);
$repository = $this->createRepository($entityManager, $metadata);
return $this->repositoryList[$emId][$entityName] = $repository;
}