Annotations
3 years ago
EntityTraits
2 years ago
EventListeners
2 years ago
Types
3 years ago
Validator
3 years ago
ArrayCache.php
3 years ago
CacheOnlyMappingDriver.php
3 years ago
ConfigurationFactory.php
3 years ago
ConnectionFactory.php
3 years ago
EntityManagerFactory.php
2 years ago
MetadataCache.php
2 years ago
PSRArrayCache.php
3 years ago
PSRCacheInvalidArgumentException.php
3 years ago
PSRCacheItem.php
3 years ago
PSRMetadataCache.php
3 years ago
ProxyClassNameResolver.php
3 years ago
Repository.php
2 years ago
SerializableConnection.php
3 years ago
TablePrefixMetadataFactory.php
2 years ago
index.php
3 years ago
ProxyClassNameResolver.php
30 lines
| 1 | <?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing |
| 2 | |
| 3 | namespace MailPoet\Doctrine; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoetVendor\Doctrine\Persistence\Mapping\ProxyClassNameResolver as IProxyClassNameResolver; |
| 9 | |
| 10 | /** |
| 11 | * This is exact copy of an anonymous class from \MailPoetVendor\Doctrine\Persistence\Mapping\AbstractClassMetadataFactory |
| 12 | * We need to use a non-anonymous class so that it is serializable within integration tests |
| 13 | * @see https://github.com/doctrine/persistence/blob/2.2.x/lib/Doctrine/Persistence/Mapping/AbstractClassMetadataFactory.php#L516-L536 |
| 14 | */ |
| 15 | class ProxyClassNameResolver implements IProxyClassNameResolver { |
| 16 | /** |
| 17 | * @template T |
| 18 | * @return class-string<T> |
| 19 | */ |
| 20 | public function resolveClassName(string $className): string { |
| 21 | $pos = \strrpos($className, '\\' . \MailPoetVendor\Doctrine\Persistence\Proxy::MARKER . '\\'); |
| 22 | if ($pos === \false) { |
| 23 | /** @var class-string<T> */ |
| 24 | return $className; |
| 25 | } |
| 26 | /** @var class-string<T> */ |
| 27 | return \substr($className, $pos + \MailPoetVendor\Doctrine\Persistence\Proxy::MARKER_LENGTH + 2); |
| 28 | } |
| 29 | } |
| 30 |