Subiendo proyecto completo sin restricciones de git ignore
This commit is contained in:
11
vendor/doctrine/persistence/CONTRIBUTING.md
vendored
Normal file
11
vendor/doctrine/persistence/CONTRIBUTING.md
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# Circular dependency
|
||||
|
||||
This package has a development dependency on `doctrine/common`, which has a
|
||||
regular dependency on this package (`^2.0` at the time of writing).
|
||||
|
||||
To be able to use Composer, one has to let it understand that this is version 2
|
||||
(even when developing on 3.0.x), as follows:
|
||||
|
||||
```shell
|
||||
COMPOSER_ROOT_VERSION=2.0 composer update -v
|
||||
```
|
||||
19
vendor/doctrine/persistence/LICENSE
vendored
Normal file
19
vendor/doctrine/persistence/LICENSE
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2006-2015 Doctrine Project
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
12
vendor/doctrine/persistence/README.md
vendored
Normal file
12
vendor/doctrine/persistence/README.md
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# Doctrine Persistence
|
||||
|
||||
[](https://travis-ci.org/doctrine/persistence)
|
||||
[](https://codecov.io/gh/doctrine/persistence/branch/2.1.x)
|
||||
|
||||
The Doctrine Persistence project is a library that provides common abstractions for object mapper persistence.
|
||||
|
||||
## More resources:
|
||||
|
||||
* [Website](https://www.doctrine-project.org/)
|
||||
* [Documentation](https://www.doctrine-project.org/projects/doctrine-persistence/en/latest/index.html)
|
||||
* [Downloads](https://github.com/doctrine/persistence/releases)
|
||||
152
vendor/doctrine/persistence/UPGRADE.md
vendored
Normal file
152
vendor/doctrine/persistence/UPGRADE.md
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
Note about upgrading: Doctrine uses static and runtime mechanisms to raise
|
||||
awareness about deprecated code.
|
||||
|
||||
- Use of `@deprecated` docblock that is detected by IDEs (like PHPStorm) or
|
||||
Static Analysis tools (like Psalm, phpstan)
|
||||
- Use of our low-overhead runtime deprecation API, details:
|
||||
https://github.com/doctrine/deprecations/
|
||||
|
||||
# Upgrade to 3.1
|
||||
|
||||
## Added method `Proxy::__setInitialized()`
|
||||
|
||||
Classes implementing `Doctrine\Persistence\Proxy` should implement the new
|
||||
method. This method will be added to the interface in 4.0.
|
||||
|
||||
## Deprecated `RuntimePublicReflectionProperty`
|
||||
|
||||
Use `RuntimeReflectionProperty` instead.
|
||||
|
||||
# Upgrade to 3.0
|
||||
|
||||
## Removed `OnClearEventArgs::clearsAllEntities()` and `OnClearEventArgs::getEntityClass()`
|
||||
|
||||
These methods only make sense when partially clearing the object manager, which
|
||||
is no longer possible.
|
||||
The second argument of the constructor of `OnClearEventArgs` is removed as well.
|
||||
|
||||
## BC Break: removed `ObjectManagerAware`
|
||||
|
||||
Implement active record style functionality directly in your application, by
|
||||
using a `postLoad` event.
|
||||
|
||||
## BC Break: removed `AnnotationDriver`
|
||||
|
||||
Use `ColocatedMappingDriver` instead.
|
||||
|
||||
## BC Break: Removed `MappingException::pathRequired()`
|
||||
|
||||
Use `MappingException::pathRequiredForDriver()` instead.
|
||||
|
||||
## BC Break: removed `LifecycleEventArgs::getEntity()`
|
||||
|
||||
Use `LifecycleEventArgs::getObject()` instead.
|
||||
|
||||
## BC Break: removed support for short namespace aliases
|
||||
|
||||
- `AbstractClassMetadataFactory::getFqcnFromAlias()` is removed.
|
||||
- `ClassMetadataFactory` methods now require their `$className` argument to be an
|
||||
actual FQCN.
|
||||
|
||||
## BC Break: removed `ObjectManager::merge()`
|
||||
|
||||
`ObjectManagerDecorator::merge()` is removed without replacement.
|
||||
|
||||
## BC Break: removed support for `doctrine/cache`
|
||||
|
||||
Removed support for using doctrine/cache for metadata caching. The
|
||||
`setCacheDriver` and `getCacheDriver` methods have been removed from
|
||||
`Doctrine\Persistence\Mapping\AbstractMetadata`. Please use `getCache` and
|
||||
`setCache` with a PSR-6 implementation instead.
|
||||
|
||||
## BC Break: changed signatures
|
||||
|
||||
`$objectName` has been dropped from the signature of `ObjectManager::clear()`.
|
||||
|
||||
```diff
|
||||
- public function clear($objectName = null)
|
||||
+ public function clear(): void
|
||||
```
|
||||
|
||||
Also, native parameter type declarations have been added on all public APIs.
|
||||
Native return type declarations have not been added so that it is possible to
|
||||
implement types compatible with both 2.x and 3.x.
|
||||
|
||||
## BC Break: Removed `PersistentObject`
|
||||
|
||||
Please implement this functionality directly in your application if you want
|
||||
ActiveRecord style functionality.
|
||||
|
||||
# Upgrade to 2.5
|
||||
|
||||
## Deprecated `OnClearEventArgs::clearsAllEntities()` and `OnClearEventArgs::getEntityClass()`
|
||||
|
||||
These methods only make sense when partially clearing the object manager, which
|
||||
is deprecated.
|
||||
Passing a second argument to the constructor of `OnClearEventArgs` is
|
||||
deprecated as well.
|
||||
|
||||
## Deprecated `ObjectManagerAware`
|
||||
|
||||
Along with deprecating `PersistentObject`, deprecating `ObjectManagerAware`
|
||||
means deprecating support for active record, which already came with a word of
|
||||
warning. Please implement this directly in your application with a `postLoad`
|
||||
event if you need active record style functionality.
|
||||
|
||||
## Deprecated `MappingException::pathRequired()`
|
||||
|
||||
`MappingException::pathRequiredForDriver()` should be used instead.
|
||||
|
||||
# Upgrade to 2.4
|
||||
|
||||
## Deprecated `AnnotationDriver`
|
||||
|
||||
Since attributes were introduced in PHP 8.0, annotations are deprecated.
|
||||
`AnnotationDriver` is an abstract class that is used when implementing concrete
|
||||
annotation drivers in dependent packages. It is deprecated in favor of using
|
||||
`ColocatedMappingDriver` to implement both annotation and attribute based
|
||||
drivers. This will involve implementing `isTransient()` as well as
|
||||
`__construct()` and `getReader()` to retain backward compatibility.
|
||||
|
||||
# Upgrade to 2.3
|
||||
|
||||
## Deprecated using short namespace alias syntax in favor of `::class` syntax.
|
||||
|
||||
Before:
|
||||
|
||||
```php
|
||||
$objectManager->find('MyPackage:MyClass', $id);
|
||||
$objectManager->createQuery('SELECT u FROM MyPackage:MyClass');
|
||||
```
|
||||
|
||||
After:
|
||||
|
||||
```php
|
||||
$objectManager->find(MyClass::class, $id);
|
||||
$objectManager->createQuery('SELECT u FROM '. MyClass::class);
|
||||
```
|
||||
|
||||
# Upgrade to 2.2
|
||||
|
||||
## Deprecated `doctrine/cache` usage for metadata caching
|
||||
|
||||
The `setCacheDriver` and `getCacheDriver` methods in
|
||||
`Doctrine\Persistence\Mapping\AbstractMetadata` have been deprecated. Please
|
||||
use `getCache` and `setCache` with a PSR-6 implementation instead. Note that
|
||||
even after switching to PSR-6, `getCacheDriver` will return a cache instance
|
||||
that wraps the PSR-6 cache. Note that if you use a custom implementation of
|
||||
doctrine/cache, the library may not be able to provide a forward compatibility
|
||||
layer. The cache implementation MUST extend the
|
||||
`Doctrine\Common\Cache\CacheProvider` class.
|
||||
|
||||
# Upgrade to 1.2
|
||||
|
||||
## Deprecated `ObjectManager::merge()` and `ObjectManager::detach()`
|
||||
|
||||
Please handle merge operations in your application, and use
|
||||
`ObjectManager::clear()` instead.
|
||||
|
||||
## Deprecated `PersistentObject`
|
||||
|
||||
Please implement this functionality directly in your application if you want
|
||||
ActiveRecord style functionality.
|
||||
59
vendor/doctrine/persistence/composer.json
vendored
Normal file
59
vendor/doctrine/persistence/composer.json
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"name": "doctrine/persistence",
|
||||
"type": "library",
|
||||
"description": "The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers share.",
|
||||
"keywords": [
|
||||
"persistence",
|
||||
"object",
|
||||
"mapper",
|
||||
"orm",
|
||||
"odm"
|
||||
],
|
||||
"homepage": "https://www.doctrine-project.org/projects/persistence.html",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{"name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com"},
|
||||
{"name": "Roman Borschel", "email": "roman@code-factory.org"},
|
||||
{"name": "Benjamin Eberlei", "email": "kontakt@beberlei.de"},
|
||||
{"name": "Jonathan Wage", "email": "jonwage@gmail.com"},
|
||||
{"name": "Johannes Schmitt", "email": "schmittjoh@gmail.com"},
|
||||
{"name": "Marco Pivetta", "email": "ocramius@gmail.com"}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.2 || ^8.0",
|
||||
"doctrine/event-manager": "^1 || ^2",
|
||||
"psr/cache": "^1.0 || ^2.0 || ^3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"composer/package-versions-deprecated": "^1.11",
|
||||
"phpstan/phpstan": "1.9.4",
|
||||
"phpstan/phpstan-phpunit": "^1",
|
||||
"phpstan/phpstan-strict-rules": "^1.1",
|
||||
"doctrine/coding-standard": "^11",
|
||||
"doctrine/common": "^3.0",
|
||||
"phpunit/phpunit": "^8.5 || ^9.5",
|
||||
"symfony/cache": "^4.4 || ^5.4 || ^6.0",
|
||||
"vimeo/psalm": "4.30.0 || 5.3.0"
|
||||
},
|
||||
"conflict": {
|
||||
"doctrine/common": "<2.10"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Doctrine\\Persistence\\": "src/Persistence"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Doctrine\\Tests\\": "tests",
|
||||
"Doctrine\\Tests_PHP74\\": "tests_php74",
|
||||
"Doctrine\\Tests_PHP81\\": "tests_php81"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true,
|
||||
"composer/package-versions-deprecated": true
|
||||
}
|
||||
}
|
||||
}
|
||||
11
vendor/doctrine/persistence/psalm-baseline.xml
vendored
Normal file
11
vendor/doctrine/persistence/psalm-baseline.xml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<files psalm-version="5.3.0@b6faa3e96b8eb50ec71384c53799b8a107236bb6">
|
||||
<file src="src/Persistence/AbstractManagerRegistry.php">
|
||||
<PossiblyNullReference occurrences="1">
|
||||
<code>getName</code>
|
||||
</PossiblyNullReference>
|
||||
<TypeDoesNotContainType occurrences="1">
|
||||
<code>$parentClass === false</code>
|
||||
</TypeDoesNotContainType>
|
||||
</file>
|
||||
</files>
|
||||
12
vendor/doctrine/persistence/psalm.phpstub
vendored
Normal file
12
vendor/doctrine/persistence/psalm.phpstub
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Workaround for psalm to return a class-string when used with a class string
|
||||
* Can be removed when https://github.com/vimeo/psalm/pull/8219 is released
|
||||
*
|
||||
* @psalm-pure
|
||||
*
|
||||
* @return ($string is class-string ? ($characters is '\\' ? class-string : string) : string)
|
||||
*
|
||||
* @psalm-flow ($string) -> return
|
||||
*/
|
||||
function ltrim(string $string, string $characters = " \t\n\r\0\x0B") : string {}
|
||||
263
vendor/doctrine/persistence/src/Persistence/AbstractManagerRegistry.php
vendored
Normal file
263
vendor/doctrine/persistence/src/Persistence/AbstractManagerRegistry.php
vendored
Normal file
@@ -0,0 +1,263 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use ReflectionClass;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* Abstract implementation of the ManagerRegistry contract.
|
||||
*/
|
||||
abstract class AbstractManagerRegistry implements ManagerRegistry
|
||||
{
|
||||
/** @var string */
|
||||
private $name;
|
||||
|
||||
/** @var array<string, string> */
|
||||
private $connections;
|
||||
|
||||
/** @var array<string, string> */
|
||||
private $managers;
|
||||
|
||||
/** @var string */
|
||||
private $defaultConnection;
|
||||
|
||||
/** @var string */
|
||||
private $defaultManager;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @psalm-var class-string
|
||||
*/
|
||||
private $proxyInterfaceName;
|
||||
|
||||
/**
|
||||
* @param array<string, string> $connections
|
||||
* @param array<string, string> $managers
|
||||
* @psalm-param class-string $proxyInterfaceName
|
||||
*/
|
||||
public function __construct(
|
||||
string $name,
|
||||
array $connections,
|
||||
array $managers,
|
||||
string $defaultConnection,
|
||||
string $defaultManager,
|
||||
string $proxyInterfaceName
|
||||
) {
|
||||
$this->name = $name;
|
||||
$this->connections = $connections;
|
||||
$this->managers = $managers;
|
||||
$this->defaultConnection = $defaultConnection;
|
||||
$this->defaultManager = $defaultManager;
|
||||
$this->proxyInterfaceName = $proxyInterfaceName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches/creates the given services.
|
||||
*
|
||||
* A service in this context is connection or a manager instance.
|
||||
*
|
||||
* @param string $name The name of the service.
|
||||
*
|
||||
* @return ObjectManager The instance of the given service.
|
||||
*/
|
||||
abstract protected function getService(string $name);
|
||||
|
||||
/**
|
||||
* Resets the given services.
|
||||
*
|
||||
* A service in this context is connection or a manager instance.
|
||||
*
|
||||
* @param string $name The name of the service.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function resetService(string $name);
|
||||
|
||||
/**
|
||||
* Gets the name of the registry.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getConnection(?string $name = null)
|
||||
{
|
||||
if ($name === null) {
|
||||
$name = $this->defaultConnection;
|
||||
}
|
||||
|
||||
if (! isset($this->connections[$name])) {
|
||||
throw new InvalidArgumentException(
|
||||
sprintf('Doctrine %s Connection named "%s" does not exist.', $this->name, $name)
|
||||
);
|
||||
}
|
||||
|
||||
return $this->getService($this->connections[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getConnectionNames()
|
||||
{
|
||||
return $this->connections;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getConnections()
|
||||
{
|
||||
$connections = [];
|
||||
foreach ($this->connections as $name => $id) {
|
||||
$connections[$name] = $this->getService($id);
|
||||
}
|
||||
|
||||
return $connections;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDefaultConnectionName()
|
||||
{
|
||||
return $this->defaultConnection;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDefaultManagerName()
|
||||
{
|
||||
return $this->defaultManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function getManager(?string $name = null)
|
||||
{
|
||||
if ($name === null) {
|
||||
$name = $this->defaultManager;
|
||||
}
|
||||
|
||||
if (! isset($this->managers[$name])) {
|
||||
throw new InvalidArgumentException(
|
||||
sprintf('Doctrine %s Manager named "%s" does not exist.', $this->name, $name)
|
||||
);
|
||||
}
|
||||
|
||||
return $this->getService($this->managers[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getManagerForClass(string $class)
|
||||
{
|
||||
$proxyClass = new ReflectionClass($class);
|
||||
if ($proxyClass->isAnonymous()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($proxyClass->implementsInterface($this->proxyInterfaceName)) {
|
||||
$parentClass = $proxyClass->getParentClass();
|
||||
|
||||
if ($parentClass === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$class = $parentClass->getName();
|
||||
}
|
||||
|
||||
foreach ($this->managers as $id) {
|
||||
$manager = $this->getService($id);
|
||||
|
||||
if (! $manager->getMetadataFactory()->isTransient($class)) {
|
||||
return $manager;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getManagerNames()
|
||||
{
|
||||
return $this->managers;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getManagers()
|
||||
{
|
||||
$managers = [];
|
||||
|
||||
foreach ($this->managers as $name => $id) {
|
||||
$manager = $this->getService($id);
|
||||
$managers[$name] = $manager;
|
||||
}
|
||||
|
||||
return $managers;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRepository(
|
||||
string $persistentObject,
|
||||
?string $persistentManagerName = null
|
||||
) {
|
||||
return $this
|
||||
->selectManager($persistentObject, $persistentManagerName)
|
||||
->getRepository($persistentObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function resetManager(?string $name = null)
|
||||
{
|
||||
if ($name === null) {
|
||||
$name = $this->defaultManager;
|
||||
}
|
||||
|
||||
if (! isset($this->managers[$name])) {
|
||||
throw new InvalidArgumentException(sprintf('Doctrine %s Manager named "%s" does not exist.', $this->name, $name));
|
||||
}
|
||||
|
||||
// force the creation of a new document manager
|
||||
// if the current one is closed
|
||||
$this->resetService($this->managers[$name]);
|
||||
|
||||
return $this->getManager($name);
|
||||
}
|
||||
|
||||
/** @psalm-param class-string $persistentObject */
|
||||
private function selectManager(
|
||||
string $persistentObject,
|
||||
?string $persistentManagerName = null
|
||||
): ObjectManager {
|
||||
if ($persistentManagerName !== null) {
|
||||
return $this->getManager($persistentManagerName);
|
||||
}
|
||||
|
||||
return $this->getManagerForClass($persistentObject) ?? $this->getManager();
|
||||
}
|
||||
}
|
||||
41
vendor/doctrine/persistence/src/Persistence/ConnectionRegistry.php
vendored
Normal file
41
vendor/doctrine/persistence/src/Persistence/ConnectionRegistry.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence;
|
||||
|
||||
/**
|
||||
* Contract covering connection for a Doctrine persistence layer ManagerRegistry class to implement.
|
||||
*/
|
||||
interface ConnectionRegistry
|
||||
{
|
||||
/**
|
||||
* Gets the default connection name.
|
||||
*
|
||||
* @return string The default connection name.
|
||||
*/
|
||||
public function getDefaultConnectionName();
|
||||
|
||||
/**
|
||||
* Gets the named connection.
|
||||
*
|
||||
* @param string|null $name The connection name (null for the default one).
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function getConnection(?string $name = null);
|
||||
|
||||
/**
|
||||
* Gets an array of all registered connections.
|
||||
*
|
||||
* @return array<string, object> An array of Connection instances.
|
||||
*/
|
||||
public function getConnections();
|
||||
|
||||
/**
|
||||
* Gets all connection names.
|
||||
*
|
||||
* @return array<string, string> An array of connection names.
|
||||
*/
|
||||
public function getConnectionNames();
|
||||
}
|
||||
54
vendor/doctrine/persistence/src/Persistence/Event/LifecycleEventArgs.php
vendored
Normal file
54
vendor/doctrine/persistence/src/Persistence/Event/LifecycleEventArgs.php
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence\Event;
|
||||
|
||||
use Doctrine\Common\EventArgs;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
|
||||
/**
|
||||
* Lifecycle Events are triggered by the UnitOfWork during lifecycle transitions
|
||||
* of entities.
|
||||
*
|
||||
* @template-covariant TObjectManager of ObjectManager
|
||||
*/
|
||||
class LifecycleEventArgs extends EventArgs
|
||||
{
|
||||
/**
|
||||
* @var ObjectManager
|
||||
* @psalm-var TObjectManager
|
||||
*/
|
||||
private $objectManager;
|
||||
|
||||
/** @var object */
|
||||
private $object;
|
||||
|
||||
/** @psalm-param TObjectManager $objectManager */
|
||||
public function __construct(object $object, ObjectManager $objectManager)
|
||||
{
|
||||
$this->object = $object;
|
||||
$this->objectManager = $objectManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the associated object.
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function getObject()
|
||||
{
|
||||
return $this->object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the associated ObjectManager.
|
||||
*
|
||||
* @return ObjectManager
|
||||
* @psalm-return TObjectManager
|
||||
*/
|
||||
public function getObjectManager()
|
||||
{
|
||||
return $this->objectManager;
|
||||
}
|
||||
}
|
||||
61
vendor/doctrine/persistence/src/Persistence/Event/LoadClassMetadataEventArgs.php
vendored
Normal file
61
vendor/doctrine/persistence/src/Persistence/Event/LoadClassMetadataEventArgs.php
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence\Event;
|
||||
|
||||
use Doctrine\Common\EventArgs;
|
||||
use Doctrine\Persistence\Mapping\ClassMetadata;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
|
||||
/**
|
||||
* Class that holds event arguments for a loadMetadata event.
|
||||
*
|
||||
* @template-covariant TClassMetadata of ClassMetadata<object>
|
||||
* @template-covariant TObjectManager of ObjectManager
|
||||
*/
|
||||
class LoadClassMetadataEventArgs extends EventArgs
|
||||
{
|
||||
/**
|
||||
* @var ClassMetadata
|
||||
* @psalm-var TClassMetadata
|
||||
*/
|
||||
private $classMetadata;
|
||||
|
||||
/**
|
||||
* @var ObjectManager
|
||||
* @psalm-var TObjectManager
|
||||
*/
|
||||
private $objectManager;
|
||||
|
||||
/**
|
||||
* @psalm-param TClassMetadata $classMetadata
|
||||
* @psalm-param TObjectManager $objectManager
|
||||
*/
|
||||
public function __construct(ClassMetadata $classMetadata, ObjectManager $objectManager)
|
||||
{
|
||||
$this->classMetadata = $classMetadata;
|
||||
$this->objectManager = $objectManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the associated ClassMetadata.
|
||||
*
|
||||
* @return ClassMetadata
|
||||
* @psalm-return TClassMetadata
|
||||
*/
|
||||
public function getClassMetadata()
|
||||
{
|
||||
return $this->classMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the associated ObjectManager.
|
||||
*
|
||||
* @return TObjectManager
|
||||
*/
|
||||
public function getObjectManager()
|
||||
{
|
||||
return $this->objectManager;
|
||||
}
|
||||
}
|
||||
39
vendor/doctrine/persistence/src/Persistence/Event/ManagerEventArgs.php
vendored
Normal file
39
vendor/doctrine/persistence/src/Persistence/Event/ManagerEventArgs.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence\Event;
|
||||
|
||||
use Doctrine\Common\EventArgs;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
|
||||
/**
|
||||
* Provides event arguments for the preFlush event.
|
||||
*
|
||||
* @template-covariant TObjectManager of ObjectManager
|
||||
*/
|
||||
class ManagerEventArgs extends EventArgs
|
||||
{
|
||||
/**
|
||||
* @var ObjectManager
|
||||
* @psalm-var TObjectManager
|
||||
*/
|
||||
private $objectManager;
|
||||
|
||||
/** @psalm-param TObjectManager $objectManager */
|
||||
public function __construct(ObjectManager $objectManager)
|
||||
{
|
||||
$this->objectManager = $objectManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the associated ObjectManager.
|
||||
*
|
||||
* @return ObjectManager
|
||||
* @psalm-return TObjectManager
|
||||
*/
|
||||
public function getObjectManager()
|
||||
{
|
||||
return $this->objectManager;
|
||||
}
|
||||
}
|
||||
42
vendor/doctrine/persistence/src/Persistence/Event/OnClearEventArgs.php
vendored
Normal file
42
vendor/doctrine/persistence/src/Persistence/Event/OnClearEventArgs.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence\Event;
|
||||
|
||||
use Doctrine\Common\EventArgs;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
|
||||
/**
|
||||
* Provides event arguments for the onClear event.
|
||||
*
|
||||
* @template-covariant TObjectManager of ObjectManager
|
||||
*/
|
||||
class OnClearEventArgs extends EventArgs
|
||||
{
|
||||
/**
|
||||
* @var ObjectManager
|
||||
* @psalm-var TObjectManager
|
||||
*/
|
||||
private $objectManager;
|
||||
|
||||
/**
|
||||
* @param ObjectManager $objectManager The object manager.
|
||||
* @psalm-param TObjectManager $objectManager
|
||||
*/
|
||||
public function __construct(ObjectManager $objectManager)
|
||||
{
|
||||
$this->objectManager = $objectManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the associated ObjectManager.
|
||||
*
|
||||
* @return ObjectManager
|
||||
* @psalm-return TObjectManager
|
||||
*/
|
||||
public function getObjectManager()
|
||||
{
|
||||
return $this->objectManager;
|
||||
}
|
||||
}
|
||||
110
vendor/doctrine/persistence/src/Persistence/Event/PreUpdateEventArgs.php
vendored
Normal file
110
vendor/doctrine/persistence/src/Persistence/Event/PreUpdateEventArgs.php
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence\Event;
|
||||
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use InvalidArgumentException;
|
||||
|
||||
use function get_class;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* Class that holds event arguments for a preUpdate event.
|
||||
*
|
||||
* @template-covariant TObjectManager of ObjectManager
|
||||
* @extends LifecycleEventArgs<TObjectManager>
|
||||
*/
|
||||
class PreUpdateEventArgs extends LifecycleEventArgs
|
||||
{
|
||||
/** @var array<string, array<int, mixed>> */
|
||||
private $entityChangeSet;
|
||||
|
||||
/**
|
||||
* @param array<string, array<int, mixed>> $changeSet
|
||||
* @psalm-param TObjectManager $objectManager
|
||||
*/
|
||||
public function __construct(object $entity, ObjectManager $objectManager, array &$changeSet)
|
||||
{
|
||||
parent::__construct($entity, $objectManager);
|
||||
|
||||
$this->entityChangeSet = &$changeSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the entity changeset.
|
||||
*
|
||||
* @return array<string, array<int, mixed>>
|
||||
*/
|
||||
public function getEntityChangeSet()
|
||||
{
|
||||
return $this->entityChangeSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if field has a changeset.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasChangedField(string $field)
|
||||
{
|
||||
return isset($this->entityChangeSet[$field]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the old value of the changeset of the changed field.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOldValue(string $field)
|
||||
{
|
||||
$this->assertValidField($field);
|
||||
|
||||
return $this->entityChangeSet[$field][0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the new value of the changeset of the changed field.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getNewValue(string $field)
|
||||
{
|
||||
$this->assertValidField($field);
|
||||
|
||||
return $this->entityChangeSet[$field][1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new value of this field.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setNewValue(string $field, $value)
|
||||
{
|
||||
$this->assertValidField($field);
|
||||
|
||||
$this->entityChangeSet[$field][1] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts the field exists in changeset.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
private function assertValidField(string $field)
|
||||
{
|
||||
if (! isset($this->entityChangeSet[$field])) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'Field "%s" is not a valid field of the entity "%s" in PreUpdateEventArgs.',
|
||||
$field,
|
||||
get_class($this->getObject())
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
89
vendor/doctrine/persistence/src/Persistence/ManagerRegistry.php
vendored
Normal file
89
vendor/doctrine/persistence/src/Persistence/ManagerRegistry.php
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence;
|
||||
|
||||
/**
|
||||
* Contract covering object managers for a Doctrine persistence layer ManagerRegistry class to implement.
|
||||
*/
|
||||
interface ManagerRegistry extends ConnectionRegistry
|
||||
{
|
||||
/**
|
||||
* Gets the default object manager name.
|
||||
*
|
||||
* @return string The default object manager name.
|
||||
*/
|
||||
public function getDefaultManagerName();
|
||||
|
||||
/**
|
||||
* Gets a named object manager.
|
||||
*
|
||||
* @param string|null $name The object manager name (null for the default one).
|
||||
*
|
||||
* @return ObjectManager
|
||||
*/
|
||||
public function getManager(?string $name = null);
|
||||
|
||||
/**
|
||||
* Gets an array of all registered object managers.
|
||||
*
|
||||
* @return array<string, ObjectManager> An array of ObjectManager instances
|
||||
*/
|
||||
public function getManagers();
|
||||
|
||||
/**
|
||||
* Resets a named object manager.
|
||||
*
|
||||
* This method is useful when an object manager has been closed
|
||||
* because of a rollbacked transaction AND when you think that
|
||||
* it makes sense to get a new one to replace the closed one.
|
||||
*
|
||||
* Be warned that you will get a brand new object manager as
|
||||
* the existing one is not useable anymore. This means that any
|
||||
* other object with a dependency on this object manager will
|
||||
* hold an obsolete reference. You can inject the registry instead
|
||||
* to avoid this problem.
|
||||
*
|
||||
* @param string|null $name The object manager name (null for the default one).
|
||||
*
|
||||
* @return ObjectManager
|
||||
*/
|
||||
public function resetManager(?string $name = null);
|
||||
|
||||
/**
|
||||
* Gets all object manager names and associated service IDs. A service ID
|
||||
* is a string that allows to obtain an object manager, typically from a
|
||||
* PSR-11 container.
|
||||
*
|
||||
* @return array<string,string> An array with object manager names as keys,
|
||||
* and service IDs as values.
|
||||
*/
|
||||
public function getManagerNames();
|
||||
|
||||
/**
|
||||
* Gets the ObjectRepository for a persistent object.
|
||||
*
|
||||
* @param string $persistentObject The name of the persistent object.
|
||||
* @param string|null $persistentManagerName The object manager name (null for the default one).
|
||||
* @psalm-param class-string<T> $persistentObject
|
||||
*
|
||||
* @return ObjectRepository
|
||||
* @psalm-return ObjectRepository<T>
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
public function getRepository(
|
||||
string $persistentObject,
|
||||
?string $persistentManagerName = null
|
||||
);
|
||||
|
||||
/**
|
||||
* Gets the object manager associated with a given class.
|
||||
*
|
||||
* @param class-string $class A persistent object class name.
|
||||
*
|
||||
* @return ObjectManager|null
|
||||
*/
|
||||
public function getManagerForClass(string $class);
|
||||
}
|
||||
499
vendor/doctrine/persistence/src/Persistence/Mapping/AbstractClassMetadataFactory.php
vendored
Normal file
499
vendor/doctrine/persistence/src/Persistence/Mapping/AbstractClassMetadataFactory.php
vendored
Normal file
@@ -0,0 +1,499 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence\Mapping;
|
||||
|
||||
use Doctrine\Persistence\Mapping\Driver\MappingDriver;
|
||||
use Doctrine\Persistence\Proxy;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use ReflectionClass;
|
||||
use ReflectionException;
|
||||
|
||||
use function array_combine;
|
||||
use function array_keys;
|
||||
use function array_map;
|
||||
use function array_reverse;
|
||||
use function array_unshift;
|
||||
use function assert;
|
||||
use function class_exists;
|
||||
use function ltrim;
|
||||
use function str_replace;
|
||||
use function strpos;
|
||||
use function strrpos;
|
||||
use function substr;
|
||||
|
||||
/**
|
||||
* The ClassMetadataFactory is used to create ClassMetadata objects that contain all the
|
||||
* metadata mapping informations of a class which describes how a class should be mapped
|
||||
* to a relational database.
|
||||
*
|
||||
* This class was abstracted from the ORM ClassMetadataFactory.
|
||||
*
|
||||
* @template CMTemplate of ClassMetadata
|
||||
* @template-implements ClassMetadataFactory<CMTemplate>
|
||||
*/
|
||||
abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
||||
{
|
||||
/**
|
||||
* Salt used by specific Object Manager implementation.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $cacheSalt = '__CLASSMETADATA__';
|
||||
|
||||
/** @var CacheItemPoolInterface|null */
|
||||
private $cache;
|
||||
|
||||
/**
|
||||
* @var array<string, ClassMetadata>
|
||||
* @psalm-var CMTemplate[]
|
||||
*/
|
||||
private $loadedMetadata = [];
|
||||
|
||||
/** @var bool */
|
||||
protected $initialized = false;
|
||||
|
||||
/** @var ReflectionService|null */
|
||||
private $reflectionService = null;
|
||||
|
||||
/** @var ProxyClassNameResolver|null */
|
||||
private $proxyClassNameResolver = null;
|
||||
|
||||
public function setCache(CacheItemPoolInterface $cache): void
|
||||
{
|
||||
$this->cache = $cache;
|
||||
}
|
||||
|
||||
final protected function getCache(): ?CacheItemPoolInterface
|
||||
{
|
||||
return $this->cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of all the loaded metadata currently in memory.
|
||||
*
|
||||
* @return ClassMetadata[]
|
||||
* @psalm-return CMTemplate[]
|
||||
*/
|
||||
public function getLoadedMetadata()
|
||||
{
|
||||
return $this->loadedMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getAllMetadata()
|
||||
{
|
||||
if (! $this->initialized) {
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
$driver = $this->getDriver();
|
||||
$metadata = [];
|
||||
foreach ($driver->getAllClassNames() as $className) {
|
||||
$metadata[] = $this->getMetadataFor($className);
|
||||
}
|
||||
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
public function setProxyClassNameResolver(ProxyClassNameResolver $resolver): void
|
||||
{
|
||||
$this->proxyClassNameResolver = $resolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lazy initialization of this stuff, especially the metadata driver,
|
||||
* since these are not needed at all when a metadata cache is active.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function initialize();
|
||||
|
||||
/**
|
||||
* Returns the mapping driver implementation.
|
||||
*
|
||||
* @return MappingDriver
|
||||
*/
|
||||
abstract protected function getDriver();
|
||||
|
||||
/**
|
||||
* Wakes up reflection after ClassMetadata gets unserialized from cache.
|
||||
*
|
||||
* @psalm-param CMTemplate $class
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function wakeupReflection(
|
||||
ClassMetadata $class,
|
||||
ReflectionService $reflService
|
||||
);
|
||||
|
||||
/**
|
||||
* Initializes Reflection after ClassMetadata was constructed.
|
||||
*
|
||||
* @psalm-param CMTemplate $class
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function initializeReflection(
|
||||
ClassMetadata $class,
|
||||
ReflectionService $reflService
|
||||
);
|
||||
|
||||
/**
|
||||
* Checks whether the class metadata is an entity.
|
||||
*
|
||||
* This method should return false for mapped superclasses or embedded classes.
|
||||
*
|
||||
* @psalm-param CMTemplate $class
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function isEntity(ClassMetadata $class);
|
||||
|
||||
/**
|
||||
* Removes the prepended backslash of a class string to conform with how php outputs class names
|
||||
*
|
||||
* @psalm-param class-string $className
|
||||
*
|
||||
* @psalm-return class-string
|
||||
*/
|
||||
private function normalizeClassName(string $className): string
|
||||
{
|
||||
return ltrim($className, '\\');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @throws ReflectionException
|
||||
* @throws MappingException
|
||||
*/
|
||||
public function getMetadataFor(string $className)
|
||||
{
|
||||
$className = $this->normalizeClassName($className);
|
||||
|
||||
if (isset($this->loadedMetadata[$className])) {
|
||||
return $this->loadedMetadata[$className];
|
||||
}
|
||||
|
||||
if (class_exists($className, false) && (new ReflectionClass($className))->isAnonymous()) {
|
||||
throw MappingException::classIsAnonymous($className);
|
||||
}
|
||||
|
||||
if (! class_exists($className, false) && strpos($className, ':') !== false) {
|
||||
throw MappingException::nonExistingClass($className);
|
||||
}
|
||||
|
||||
$realClassName = $this->getRealClass($className);
|
||||
|
||||
if (isset($this->loadedMetadata[$realClassName])) {
|
||||
// We do not have the alias name in the map, include it
|
||||
return $this->loadedMetadata[$className] = $this->loadedMetadata[$realClassName];
|
||||
}
|
||||
|
||||
try {
|
||||
if ($this->cache !== null) {
|
||||
$cached = $this->cache->getItem($this->getCacheKey($realClassName))->get();
|
||||
if ($cached instanceof ClassMetadata) {
|
||||
/** @psalm-var CMTemplate $cached */
|
||||
$this->loadedMetadata[$realClassName] = $cached;
|
||||
|
||||
$this->wakeupReflection($cached, $this->getReflectionService());
|
||||
} else {
|
||||
$loadedMetadata = $this->loadMetadata($realClassName);
|
||||
$classNames = array_combine(
|
||||
array_map([$this, 'getCacheKey'], $loadedMetadata),
|
||||
$loadedMetadata
|
||||
);
|
||||
|
||||
foreach ($this->cache->getItems(array_keys($classNames)) as $item) {
|
||||
if (! isset($classNames[$item->getKey()])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$item->set($this->loadedMetadata[$classNames[$item->getKey()]]);
|
||||
$this->cache->saveDeferred($item);
|
||||
}
|
||||
|
||||
$this->cache->commit();
|
||||
}
|
||||
} else {
|
||||
$this->loadMetadata($realClassName);
|
||||
}
|
||||
} catch (MappingException $loadingException) {
|
||||
$fallbackMetadataResponse = $this->onNotFoundMetadata($realClassName);
|
||||
|
||||
if ($fallbackMetadataResponse === null) {
|
||||
throw $loadingException;
|
||||
}
|
||||
|
||||
$this->loadedMetadata[$realClassName] = $fallbackMetadataResponse;
|
||||
}
|
||||
|
||||
if ($className !== $realClassName) {
|
||||
// We do not have the alias name in the map, include it
|
||||
$this->loadedMetadata[$className] = $this->loadedMetadata[$realClassName];
|
||||
}
|
||||
|
||||
return $this->loadedMetadata[$className];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function hasMetadataFor(string $className)
|
||||
{
|
||||
$className = $this->normalizeClassName($className);
|
||||
|
||||
return isset($this->loadedMetadata[$className]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the metadata descriptor for a specific class.
|
||||
*
|
||||
* NOTE: This is only useful in very special cases, like when generating proxy classes.
|
||||
*
|
||||
* @psalm-param class-string $className
|
||||
* @psalm-param CMTemplate $class
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setMetadataFor(string $className, ClassMetadata $class)
|
||||
{
|
||||
$this->loadedMetadata[$this->normalizeClassName($className)] = $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of parent classes for the given entity class.
|
||||
*
|
||||
* @psalm-param class-string $name
|
||||
*
|
||||
* @return string[]
|
||||
* @psalm-return list<class-string>
|
||||
*/
|
||||
protected function getParentClasses(string $name)
|
||||
{
|
||||
// Collect parent classes, ignoring transient (not-mapped) classes.
|
||||
$parentClasses = [];
|
||||
|
||||
foreach (array_reverse($this->getReflectionService()->getParentClasses($name)) as $parentClass) {
|
||||
if ($this->getDriver()->isTransient($parentClass)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$parentClasses[] = $parentClass;
|
||||
}
|
||||
|
||||
return $parentClasses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the metadata of the class in question and all it's ancestors whose metadata
|
||||
* is still not loaded.
|
||||
*
|
||||
* Important: The class $name does not necessarily exist at this point here.
|
||||
* Scenarios in a code-generation setup might have access to XML/YAML
|
||||
* Mapping files without the actual PHP code existing here. That is why the
|
||||
* {@see \Doctrine\Persistence\Mapping\ReflectionService} interface
|
||||
* should be used for reflection.
|
||||
*
|
||||
* @param string $name The name of the class for which the metadata should get loaded.
|
||||
* @psalm-param class-string $name
|
||||
*
|
||||
* @return array<int, string>
|
||||
* @psalm-return list<string>
|
||||
*/
|
||||
protected function loadMetadata(string $name)
|
||||
{
|
||||
if (! $this->initialized) {
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
$loaded = [];
|
||||
|
||||
$parentClasses = $this->getParentClasses($name);
|
||||
$parentClasses[] = $name;
|
||||
|
||||
// Move down the hierarchy of parent classes, starting from the topmost class
|
||||
$parent = null;
|
||||
$rootEntityFound = false;
|
||||
$visited = [];
|
||||
$reflService = $this->getReflectionService();
|
||||
|
||||
foreach ($parentClasses as $className) {
|
||||
if (isset($this->loadedMetadata[$className])) {
|
||||
$parent = $this->loadedMetadata[$className];
|
||||
|
||||
if ($this->isEntity($parent)) {
|
||||
$rootEntityFound = true;
|
||||
|
||||
array_unshift($visited, $className);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$class = $this->newClassMetadataInstance($className);
|
||||
$this->initializeReflection($class, $reflService);
|
||||
|
||||
$this->doLoadMetadata($class, $parent, $rootEntityFound, $visited);
|
||||
|
||||
$this->loadedMetadata[$className] = $class;
|
||||
|
||||
$parent = $class;
|
||||
|
||||
if ($this->isEntity($class)) {
|
||||
$rootEntityFound = true;
|
||||
|
||||
array_unshift($visited, $className);
|
||||
}
|
||||
|
||||
$this->wakeupReflection($class, $reflService);
|
||||
|
||||
$loaded[] = $className;
|
||||
}
|
||||
|
||||
return $loaded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a fallback hook for loading metadata when loading failed due to reflection/mapping exceptions
|
||||
*
|
||||
* Override this method to implement a fallback strategy for failed metadata loading
|
||||
*
|
||||
* @return ClassMetadata|null
|
||||
* @psalm-return CMTemplate|null
|
||||
*/
|
||||
protected function onNotFoundMetadata(string $className)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Actually loads the metadata from the underlying metadata.
|
||||
*
|
||||
* @param bool $rootEntityFound True when there is another entity (non-mapped superclass) class above the current class in the PHP class hierarchy.
|
||||
* @param list<class-string> $nonSuperclassParents All parent class names that are not marked as mapped superclasses, with the direct parent class being the first and the root entity class the last element.
|
||||
* @psalm-param CMTemplate $class
|
||||
* @psalm-param CMTemplate|null $parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function doLoadMetadata(
|
||||
ClassMetadata $class,
|
||||
?ClassMetadata $parent,
|
||||
bool $rootEntityFound,
|
||||
array $nonSuperclassParents
|
||||
);
|
||||
|
||||
/**
|
||||
* Creates a new ClassMetadata instance for the given class name.
|
||||
*
|
||||
* @psalm-param class-string<T> $className
|
||||
*
|
||||
* @return ClassMetadata<T>
|
||||
* @psalm-return CMTemplate
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
abstract protected function newClassMetadataInstance(string $className);
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function isTransient(string $className)
|
||||
{
|
||||
if (! $this->initialized) {
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
if (class_exists($className, false) && (new ReflectionClass($className))->isAnonymous()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! class_exists($className, false) && strpos($className, ':') !== false) {
|
||||
throw MappingException::nonExistingClass($className);
|
||||
}
|
||||
|
||||
/** @psalm-var class-string $className */
|
||||
return $this->getDriver()->isTransient($className);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the reflectionService.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setReflectionService(ReflectionService $reflectionService)
|
||||
{
|
||||
$this->reflectionService = $reflectionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the reflection service associated with this metadata factory.
|
||||
*
|
||||
* @return ReflectionService
|
||||
*/
|
||||
public function getReflectionService()
|
||||
{
|
||||
if ($this->reflectionService === null) {
|
||||
$this->reflectionService = new RuntimeReflectionService();
|
||||
}
|
||||
|
||||
return $this->reflectionService;
|
||||
}
|
||||
|
||||
protected function getCacheKey(string $realClassName): string
|
||||
{
|
||||
return str_replace('\\', '__', $realClassName) . $this->cacheSalt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the real class name of a class name that could be a proxy.
|
||||
*
|
||||
* @psalm-param class-string<Proxy<T>>|class-string<T> $class
|
||||
*
|
||||
* @psalm-return class-string<T>
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
private function getRealClass(string $class): string
|
||||
{
|
||||
if ($this->proxyClassNameResolver === null) {
|
||||
$this->createDefaultProxyClassNameResolver();
|
||||
}
|
||||
|
||||
assert($this->proxyClassNameResolver !== null);
|
||||
|
||||
return $this->proxyClassNameResolver->resolveClassName($class);
|
||||
}
|
||||
|
||||
private function createDefaultProxyClassNameResolver(): void
|
||||
{
|
||||
$this->proxyClassNameResolver = new class implements ProxyClassNameResolver {
|
||||
/**
|
||||
* @psalm-param class-string<Proxy<T>>|class-string<T> $className
|
||||
*
|
||||
* @psalm-return class-string<T>
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
public function resolveClassName(string $className): string
|
||||
{
|
||||
$pos = strrpos($className, '\\' . Proxy::MARKER . '\\');
|
||||
|
||||
if ($pos === false) {
|
||||
/** @psalm-var class-string<T> */
|
||||
return $className;
|
||||
}
|
||||
|
||||
/** @psalm-var class-string<T> */
|
||||
return substr($className, $pos + Proxy::MARKER_LENGTH + 2);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
141
vendor/doctrine/persistence/src/Persistence/Mapping/ClassMetadata.php
vendored
Normal file
141
vendor/doctrine/persistence/src/Persistence/Mapping/ClassMetadata.php
vendored
Normal file
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence\Mapping;
|
||||
|
||||
use ReflectionClass;
|
||||
|
||||
/**
|
||||
* Contract for a Doctrine persistence layer ClassMetadata class to implement.
|
||||
*
|
||||
* @template-covariant T of object
|
||||
*/
|
||||
interface ClassMetadata
|
||||
{
|
||||
/**
|
||||
* Gets the fully-qualified class name of this persistent class.
|
||||
*
|
||||
* @return string
|
||||
* @psalm-return class-string<T>
|
||||
*/
|
||||
public function getName();
|
||||
|
||||
/**
|
||||
* Gets the mapped identifier field name.
|
||||
*
|
||||
* The returned structure is an array of the identifier field names.
|
||||
*
|
||||
* @return array<int, string>
|
||||
* @psalm-return list<string>
|
||||
*/
|
||||
public function getIdentifier();
|
||||
|
||||
/**
|
||||
* Gets the ReflectionClass instance for this mapped class.
|
||||
*
|
||||
* @return ReflectionClass<T>
|
||||
*/
|
||||
public function getReflectionClass();
|
||||
|
||||
/**
|
||||
* Checks if the given field name is a mapped identifier for this class.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isIdentifier(string $fieldName);
|
||||
|
||||
/**
|
||||
* Checks if the given field is a mapped property for this class.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasField(string $fieldName);
|
||||
|
||||
/**
|
||||
* Checks if the given field is a mapped association for this class.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAssociation(string $fieldName);
|
||||
|
||||
/**
|
||||
* Checks if the given field is a mapped single valued association for this class.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSingleValuedAssociation(string $fieldName);
|
||||
|
||||
/**
|
||||
* Checks if the given field is a mapped collection valued association for this class.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isCollectionValuedAssociation(string $fieldName);
|
||||
|
||||
/**
|
||||
* A numerically indexed list of field names of this persistent class.
|
||||
*
|
||||
* This array includes identifier fields if present on this class.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function getFieldNames();
|
||||
|
||||
/**
|
||||
* Returns an array of identifier field names numerically indexed.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function getIdentifierFieldNames();
|
||||
|
||||
/**
|
||||
* Returns a numerically indexed list of association names of this persistent class.
|
||||
*
|
||||
* This array includes identifier associations if present on this class.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function getAssociationNames();
|
||||
|
||||
/**
|
||||
* Returns a type name of this field.
|
||||
*
|
||||
* This type names can be implementation specific but should at least include the php types:
|
||||
* integer, string, boolean, float/double, datetime.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getTypeOfField(string $fieldName);
|
||||
|
||||
/**
|
||||
* Returns the target class name of the given association.
|
||||
*
|
||||
* @return string|null
|
||||
* @psalm-return class-string|null
|
||||
*/
|
||||
public function getAssociationTargetClass(string $assocName);
|
||||
|
||||
/**
|
||||
* Checks if the association is the inverse side of a bidirectional association.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isAssociationInverseSide(string $assocName);
|
||||
|
||||
/**
|
||||
* Returns the target field of the owning side of the association.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAssociationMappedByTargetField(string $assocName);
|
||||
|
||||
/**
|
||||
* Returns the identifier of this object as an array with field name as key.
|
||||
*
|
||||
* Has to return an empty array if no identifier isset.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function getIdentifierValues(object $object);
|
||||
}
|
||||
61
vendor/doctrine/persistence/src/Persistence/Mapping/ClassMetadataFactory.php
vendored
Normal file
61
vendor/doctrine/persistence/src/Persistence/Mapping/ClassMetadataFactory.php
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence\Mapping;
|
||||
|
||||
/**
|
||||
* Contract for a Doctrine persistence layer ClassMetadata class to implement.
|
||||
*
|
||||
* @template T of ClassMetadata
|
||||
*/
|
||||
interface ClassMetadataFactory
|
||||
{
|
||||
/**
|
||||
* Forces the factory to load the metadata of all classes known to the underlying
|
||||
* mapping driver.
|
||||
*
|
||||
* @return ClassMetadata[] The ClassMetadata instances of all mapped classes.
|
||||
* @psalm-return list<T>
|
||||
*/
|
||||
public function getAllMetadata();
|
||||
|
||||
/**
|
||||
* Gets the class metadata descriptor for a class.
|
||||
*
|
||||
* @param class-string $className The name of the class.
|
||||
*
|
||||
* @return ClassMetadata
|
||||
* @psalm-return T
|
||||
*/
|
||||
public function getMetadataFor(string $className);
|
||||
|
||||
/**
|
||||
* Checks whether the factory has the metadata for a class loaded already.
|
||||
*
|
||||
* @param class-string $className
|
||||
*
|
||||
* @return bool TRUE if the metadata of the class in question is already loaded, FALSE otherwise.
|
||||
*/
|
||||
public function hasMetadataFor(string $className);
|
||||
|
||||
/**
|
||||
* Sets the metadata descriptor for a specific class.
|
||||
*
|
||||
* @param class-string $className
|
||||
* @psalm-param T $class
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setMetadataFor(string $className, ClassMetadata $class);
|
||||
|
||||
/**
|
||||
* Returns whether the class with the specified name should have its metadata loaded.
|
||||
* This is only the case if it is either mapped directly or as a MappedSuperclass.
|
||||
*
|
||||
* @psalm-param class-string $className
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isTransient(string $className);
|
||||
}
|
||||
212
vendor/doctrine/persistence/src/Persistence/Mapping/Driver/ColocatedMappingDriver.php
vendored
Normal file
212
vendor/doctrine/persistence/src/Persistence/Mapping/Driver/ColocatedMappingDriver.php
vendored
Normal file
@@ -0,0 +1,212 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence\Mapping\Driver;
|
||||
|
||||
use Doctrine\Persistence\Mapping\MappingException;
|
||||
use FilesystemIterator;
|
||||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
use RecursiveRegexIterator;
|
||||
use ReflectionClass;
|
||||
use RegexIterator;
|
||||
|
||||
use function array_merge;
|
||||
use function array_unique;
|
||||
use function assert;
|
||||
use function get_declared_classes;
|
||||
use function in_array;
|
||||
use function is_dir;
|
||||
use function preg_match;
|
||||
use function preg_quote;
|
||||
use function realpath;
|
||||
use function str_replace;
|
||||
use function strpos;
|
||||
|
||||
/**
|
||||
* The ColocatedMappingDriver reads the mapping metadata located near the code.
|
||||
*/
|
||||
trait ColocatedMappingDriver
|
||||
{
|
||||
/**
|
||||
* The paths where to look for mapping files.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $paths = [];
|
||||
|
||||
/**
|
||||
* The paths excluded from path where to look for mapping files.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $excludePaths = [];
|
||||
|
||||
/**
|
||||
* The file extension of mapping documents.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $fileExtension = '.php';
|
||||
|
||||
/**
|
||||
* Cache for getAllClassNames().
|
||||
*
|
||||
* @var array<int, string>|null
|
||||
* @psalm-var list<class-string>|null
|
||||
*/
|
||||
protected $classNames;
|
||||
|
||||
/**
|
||||
* Appends lookup paths to metadata driver.
|
||||
*
|
||||
* @param array<int, string> $paths
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addPaths(array $paths)
|
||||
{
|
||||
$this->paths = array_unique(array_merge($this->paths, $paths));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the defined metadata lookup paths.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function getPaths()
|
||||
{
|
||||
return $this->paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append exclude lookup paths to metadata driver.
|
||||
*
|
||||
* @param string[] $paths
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addExcludePaths(array $paths)
|
||||
{
|
||||
$this->excludePaths = array_unique(array_merge($this->excludePaths, $paths));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the defined metadata lookup exclude paths.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function getExcludePaths()
|
||||
{
|
||||
return $this->excludePaths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the file extension used to look for mapping files under.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFileExtension()
|
||||
{
|
||||
return $this->fileExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the file extension used to look for mapping files under.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setFileExtension(string $fileExtension)
|
||||
{
|
||||
$this->fileExtension = $fileExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* Returns whether the class with the specified name is transient. Only non-transient
|
||||
* classes, that is entities and mapped superclasses, should have their metadata loaded.
|
||||
*
|
||||
* @psalm-param class-string $className
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function isTransient(string $className);
|
||||
|
||||
/**
|
||||
* Gets the names of all mapped classes known to this driver.
|
||||
*
|
||||
* @return string[] The names of all mapped classes known to this driver.
|
||||
* @psalm-return list<class-string>
|
||||
*/
|
||||
public function getAllClassNames()
|
||||
{
|
||||
if ($this->classNames !== null) {
|
||||
return $this->classNames;
|
||||
}
|
||||
|
||||
if ($this->paths === []) {
|
||||
throw MappingException::pathRequiredForDriver(static::class);
|
||||
}
|
||||
|
||||
$classes = [];
|
||||
$includedFiles = [];
|
||||
|
||||
foreach ($this->paths as $path) {
|
||||
if (! is_dir($path)) {
|
||||
throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path);
|
||||
}
|
||||
|
||||
$iterator = new RegexIterator(
|
||||
new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS),
|
||||
RecursiveIteratorIterator::LEAVES_ONLY
|
||||
),
|
||||
'/^.+' . preg_quote($this->fileExtension) . '$/i',
|
||||
RecursiveRegexIterator::GET_MATCH
|
||||
);
|
||||
|
||||
foreach ($iterator as $file) {
|
||||
$sourceFile = $file[0];
|
||||
|
||||
if (preg_match('(^phar:)i', $sourceFile) === 0) {
|
||||
$sourceFile = realpath($sourceFile);
|
||||
}
|
||||
|
||||
foreach ($this->excludePaths as $excludePath) {
|
||||
$realExcludePath = realpath($excludePath);
|
||||
assert($realExcludePath !== false);
|
||||
$exclude = str_replace('\\', '/', $realExcludePath);
|
||||
$current = str_replace('\\', '/', $sourceFile);
|
||||
|
||||
if (strpos($current, $exclude) !== false) {
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
require_once $sourceFile;
|
||||
|
||||
$includedFiles[] = $sourceFile;
|
||||
}
|
||||
}
|
||||
|
||||
$declared = get_declared_classes();
|
||||
|
||||
foreach ($declared as $className) {
|
||||
$rc = new ReflectionClass($className);
|
||||
|
||||
$sourceFile = $rc->getFileName();
|
||||
|
||||
if (! in_array($sourceFile, $includedFiles, true) || $this->isTransient($className)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$classes[] = $className;
|
||||
}
|
||||
|
||||
$this->classNames = $classes;
|
||||
|
||||
return $classes;
|
||||
}
|
||||
}
|
||||
175
vendor/doctrine/persistence/src/Persistence/Mapping/Driver/DefaultFileLocator.php
vendored
Normal file
175
vendor/doctrine/persistence/src/Persistence/Mapping/Driver/DefaultFileLocator.php
vendored
Normal file
@@ -0,0 +1,175 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence\Mapping\Driver;
|
||||
|
||||
use Doctrine\Persistence\Mapping\MappingException;
|
||||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
|
||||
use function array_merge;
|
||||
use function array_unique;
|
||||
use function assert;
|
||||
use function is_dir;
|
||||
use function is_file;
|
||||
use function is_string;
|
||||
use function str_replace;
|
||||
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
|
||||
/**
|
||||
* Locates the file that contains the metadata information for a given class name.
|
||||
*
|
||||
* This behavior is independent of the actual content of the file. It just detects
|
||||
* the file which is responsible for the given class name.
|
||||
*/
|
||||
class DefaultFileLocator implements FileLocator
|
||||
{
|
||||
/**
|
||||
* The paths where to look for mapping files.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $paths = [];
|
||||
|
||||
/**
|
||||
* The file extension of mapping documents.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $fileExtension;
|
||||
|
||||
/**
|
||||
* Initializes a new FileDriver that looks in the given path(s) for mapping
|
||||
* documents and operates in the specified operating mode.
|
||||
*
|
||||
* @param string|array<int, string> $paths One or multiple paths where mapping documents
|
||||
* can be found.
|
||||
* @param string|null $fileExtension The file extension of mapping documents,
|
||||
* usually prefixed with a dot.
|
||||
*/
|
||||
public function __construct($paths, ?string $fileExtension = null)
|
||||
{
|
||||
$this->addPaths((array) $paths);
|
||||
$this->fileExtension = $fileExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends lookup paths to metadata driver.
|
||||
*
|
||||
* @param array<int, string> $paths
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addPaths(array $paths)
|
||||
{
|
||||
$this->paths = array_unique(array_merge($this->paths, $paths));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the defined metadata lookup paths.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function getPaths()
|
||||
{
|
||||
return $this->paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the file extension used to look for mapping files under.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getFileExtension()
|
||||
{
|
||||
return $this->fileExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the file extension used to look for mapping files under.
|
||||
*
|
||||
* @param string|null $fileExtension The file extension to set.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setFileExtension(?string $fileExtension)
|
||||
{
|
||||
$this->fileExtension = $fileExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function findMappingFile(string $className)
|
||||
{
|
||||
$fileName = str_replace('\\', '.', $className) . $this->fileExtension;
|
||||
|
||||
// Check whether file exists
|
||||
foreach ($this->paths as $path) {
|
||||
if (is_file($path . DIRECTORY_SEPARATOR . $fileName)) {
|
||||
return $path . DIRECTORY_SEPARATOR . $fileName;
|
||||
}
|
||||
}
|
||||
|
||||
throw MappingException::mappingFileNotFound($className, $fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getAllClassNames(string $globalBasename)
|
||||
{
|
||||
if ($this->paths === []) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$classes = [];
|
||||
|
||||
foreach ($this->paths as $path) {
|
||||
if (! is_dir($path)) {
|
||||
throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path);
|
||||
}
|
||||
|
||||
$iterator = new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($path),
|
||||
RecursiveIteratorIterator::LEAVES_ONLY
|
||||
);
|
||||
|
||||
foreach ($iterator as $file) {
|
||||
$fileName = $file->getBasename($this->fileExtension);
|
||||
|
||||
if ($fileName === $file->getBasename() || $fileName === $globalBasename) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// NOTE: All files found here means classes are not transient!
|
||||
|
||||
assert(is_string($fileName));
|
||||
/** @psalm-var class-string */
|
||||
$class = str_replace('.', '\\', $fileName);
|
||||
$classes[] = $class;
|
||||
}
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fileExists(string $className)
|
||||
{
|
||||
$fileName = str_replace('\\', '.', $className) . $this->fileExtension;
|
||||
|
||||
// Check whether file exists
|
||||
foreach ($this->paths as $path) {
|
||||
if (is_file($path . DIRECTORY_SEPARATOR . $fileName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
212
vendor/doctrine/persistence/src/Persistence/Mapping/Driver/FileDriver.php
vendored
Normal file
212
vendor/doctrine/persistence/src/Persistence/Mapping/Driver/FileDriver.php
vendored
Normal file
@@ -0,0 +1,212 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence\Mapping\Driver;
|
||||
|
||||
use Doctrine\Persistence\Mapping\ClassMetadata;
|
||||
use Doctrine\Persistence\Mapping\MappingException;
|
||||
|
||||
use function array_keys;
|
||||
use function array_merge;
|
||||
use function array_unique;
|
||||
use function array_values;
|
||||
use function is_file;
|
||||
use function str_replace;
|
||||
|
||||
/**
|
||||
* Base driver for file-based metadata drivers.
|
||||
*
|
||||
* A file driver operates in a mode where it loads the mapping files of individual
|
||||
* classes on demand. This requires the user to adhere to the convention of 1 mapping
|
||||
* file per class and the file names of the mapping files must correspond to the full
|
||||
* class name, including namespace, with the namespace delimiters '\', replaced by dots '.'.
|
||||
*/
|
||||
abstract class FileDriver implements MappingDriver
|
||||
{
|
||||
/** @var FileLocator */
|
||||
protected $locator;
|
||||
|
||||
/**
|
||||
* @var ClassMetadata[]|null
|
||||
* @psalm-var array<class-string, ClassMetadata<object>>|null
|
||||
*/
|
||||
protected $classCache;
|
||||
|
||||
/** @var string */
|
||||
protected $globalBasename = '';
|
||||
|
||||
/**
|
||||
* Initializes a new FileDriver that looks in the given path(s) for mapping
|
||||
* documents and operates in the specified operating mode.
|
||||
*
|
||||
* @param string|array<int, string>|FileLocator $locator A FileLocator or one/multiple paths
|
||||
* where mapping documents can be found.
|
||||
*/
|
||||
public function __construct($locator, ?string $fileExtension = null)
|
||||
{
|
||||
if ($locator instanceof FileLocator) {
|
||||
$this->locator = $locator;
|
||||
} else {
|
||||
$this->locator = new DefaultFileLocator((array) $locator, $fileExtension);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the global basename.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setGlobalBasename(string $file)
|
||||
{
|
||||
$this->globalBasename = $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the global basename.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getGlobalBasename()
|
||||
{
|
||||
return $this->globalBasename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the element of schema meta data for the class from the mapping file.
|
||||
* This will lazily load the mapping file if it is not loaded yet.
|
||||
*
|
||||
* @psalm-param class-string $className
|
||||
*
|
||||
* @return ClassMetadata The element of schema meta data.
|
||||
* @psalm-return ClassMetadata<object>
|
||||
*
|
||||
* @throws MappingException
|
||||
*/
|
||||
public function getElement(string $className)
|
||||
{
|
||||
if ($this->classCache === null) {
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
if (isset($this->classCache[$className])) {
|
||||
return $this->classCache[$className];
|
||||
}
|
||||
|
||||
$result = $this->loadMappingFile($this->locator->findMappingFile($className));
|
||||
|
||||
if (! isset($result[$className])) {
|
||||
throw MappingException::invalidMappingFile(
|
||||
$className,
|
||||
str_replace('\\', '.', $className) . $this->locator->getFileExtension()
|
||||
);
|
||||
}
|
||||
|
||||
$this->classCache[$className] = $result[$className];
|
||||
|
||||
return $result[$className];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function isTransient(string $className)
|
||||
{
|
||||
if ($this->classCache === null) {
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
if (isset($this->classCache[$className])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ! $this->locator->fileExists($className);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getAllClassNames()
|
||||
{
|
||||
if ($this->classCache === null) {
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
if ($this->classCache === []) {
|
||||
return $this->locator->getAllClassNames($this->globalBasename);
|
||||
}
|
||||
|
||||
/** @psalm-var array<class-string, ClassMetadata<object>> $classCache */
|
||||
$classCache = $this->classCache;
|
||||
|
||||
/** @var list<class-string> $keys */
|
||||
$keys = array_keys($classCache);
|
||||
|
||||
return array_values(array_unique(array_merge(
|
||||
$keys,
|
||||
$this->locator->getAllClassNames($this->globalBasename)
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a mapping file with the given name and returns a map
|
||||
* from class/entity names to their corresponding file driver elements.
|
||||
*
|
||||
* @param string $file The mapping file to load.
|
||||
*
|
||||
* @return ClassMetadata[]
|
||||
* @psalm-return array<class-string, ClassMetadata<object>>
|
||||
*/
|
||||
abstract protected function loadMappingFile(string $file);
|
||||
|
||||
/**
|
||||
* Initializes the class cache from all the global files.
|
||||
*
|
||||
* Using this feature adds a substantial performance hit to file drivers as
|
||||
* more metadata has to be loaded into memory than might actually be
|
||||
* necessary. This may not be relevant to scenarios where caching of
|
||||
* metadata is in place, however hits very hard in scenarios where no
|
||||
* caching is used.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function initialize()
|
||||
{
|
||||
$this->classCache = [];
|
||||
if ($this->globalBasename === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->locator->getPaths() as $path) {
|
||||
$file = $path . '/' . $this->globalBasename . $this->locator->getFileExtension();
|
||||
if (! is_file($file)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->classCache = array_merge(
|
||||
$this->classCache,
|
||||
$this->loadMappingFile($file)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the locator used to discover mapping files by className.
|
||||
*
|
||||
* @return FileLocator
|
||||
*/
|
||||
public function getLocator()
|
||||
{
|
||||
return $this->locator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the locator used to discover mapping files by className.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setLocator(FileLocator $locator)
|
||||
{
|
||||
$this->locator = $locator;
|
||||
}
|
||||
}
|
||||
52
vendor/doctrine/persistence/src/Persistence/Mapping/Driver/FileLocator.php
vendored
Normal file
52
vendor/doctrine/persistence/src/Persistence/Mapping/Driver/FileLocator.php
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence\Mapping\Driver;
|
||||
|
||||
/**
|
||||
* Locates the file that contains the metadata information for a given class name.
|
||||
*
|
||||
* This behavior is independent of the actual content of the file. It just detects
|
||||
* the file which is responsible for the given class name.
|
||||
*/
|
||||
interface FileLocator
|
||||
{
|
||||
/**
|
||||
* Locates mapping file for the given class name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function findMappingFile(string $className);
|
||||
|
||||
/**
|
||||
* Gets all class names that are found with this file locator.
|
||||
*
|
||||
* @param string $globalBasename Passed to allow excluding the basename.
|
||||
*
|
||||
* @return array<int, string>
|
||||
* @psalm-return list<class-string>
|
||||
*/
|
||||
public function getAllClassNames(string $globalBasename);
|
||||
|
||||
/**
|
||||
* Checks if a file can be found for this class name.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function fileExists(string $className);
|
||||
|
||||
/**
|
||||
* Gets all the paths that this file locator looks for mapping files.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function getPaths();
|
||||
|
||||
/**
|
||||
* Gets the file extension that mapping files are suffixed with.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getFileExtension();
|
||||
}
|
||||
43
vendor/doctrine/persistence/src/Persistence/Mapping/Driver/MappingDriver.php
vendored
Normal file
43
vendor/doctrine/persistence/src/Persistence/Mapping/Driver/MappingDriver.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence\Mapping\Driver;
|
||||
|
||||
use Doctrine\Persistence\Mapping\ClassMetadata;
|
||||
|
||||
/**
|
||||
* Contract for metadata drivers.
|
||||
*/
|
||||
interface MappingDriver
|
||||
{
|
||||
/**
|
||||
* Loads the metadata for the specified class into the provided container.
|
||||
*
|
||||
* @psalm-param class-string<T> $className
|
||||
* @psalm-param ClassMetadata<T> $metadata
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
public function loadMetadataForClass(string $className, ClassMetadata $metadata);
|
||||
|
||||
/**
|
||||
* Gets the names of all mapped classes known to this driver.
|
||||
*
|
||||
* @return array<int, string> The names of all mapped classes known to this driver.
|
||||
* @psalm-return list<class-string>
|
||||
*/
|
||||
public function getAllClassNames();
|
||||
|
||||
/**
|
||||
* Returns whether the class with the specified name should have its metadata loaded.
|
||||
* This is only the case if it is either mapped as an Entity or a MappedSuperclass.
|
||||
*
|
||||
* @psalm-param class-string $className
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isTransient(string $className);
|
||||
}
|
||||
142
vendor/doctrine/persistence/src/Persistence/Mapping/Driver/MappingDriverChain.php
vendored
Normal file
142
vendor/doctrine/persistence/src/Persistence/Mapping/Driver/MappingDriverChain.php
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence\Mapping\Driver;
|
||||
|
||||
use Doctrine\Persistence\Mapping\ClassMetadata;
|
||||
use Doctrine\Persistence\Mapping\MappingException;
|
||||
|
||||
use function array_keys;
|
||||
use function spl_object_hash;
|
||||
use function strpos;
|
||||
|
||||
/**
|
||||
* The DriverChain allows you to add multiple other mapping drivers for
|
||||
* certain namespaces.
|
||||
*/
|
||||
class MappingDriverChain implements MappingDriver
|
||||
{
|
||||
/**
|
||||
* The default driver.
|
||||
*
|
||||
* @var MappingDriver|null
|
||||
*/
|
||||
private $defaultDriver;
|
||||
|
||||
/** @var array<string, MappingDriver> */
|
||||
private $drivers = [];
|
||||
|
||||
/**
|
||||
* Gets the default driver.
|
||||
*
|
||||
* @return MappingDriver|null
|
||||
*/
|
||||
public function getDefaultDriver()
|
||||
{
|
||||
return $this->defaultDriver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default driver.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setDefaultDriver(MappingDriver $driver)
|
||||
{
|
||||
$this->defaultDriver = $driver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a nested driver.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addDriver(MappingDriver $nestedDriver, string $namespace)
|
||||
{
|
||||
$this->drivers[$namespace] = $nestedDriver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the array of nested drivers.
|
||||
*
|
||||
* @return array<string, MappingDriver> $drivers
|
||||
*/
|
||||
public function getDrivers()
|
||||
{
|
||||
return $this->drivers;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function loadMetadataForClass(string $className, ClassMetadata $metadata)
|
||||
{
|
||||
foreach ($this->drivers as $namespace => $driver) {
|
||||
if (strpos($className, $namespace) === 0) {
|
||||
$driver->loadMetadataForClass($className, $metadata);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->defaultDriver !== null) {
|
||||
$this->defaultDriver->loadMetadataForClass($className, $metadata);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
throw MappingException::classNotFoundInNamespaces($className, array_keys($this->drivers));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getAllClassNames()
|
||||
{
|
||||
$classNames = [];
|
||||
$driverClasses = [];
|
||||
|
||||
foreach ($this->drivers as $namespace => $driver) {
|
||||
$oid = spl_object_hash($driver);
|
||||
|
||||
if (! isset($driverClasses[$oid])) {
|
||||
$driverClasses[$oid] = $driver->getAllClassNames();
|
||||
}
|
||||
|
||||
foreach ($driverClasses[$oid] as $className) {
|
||||
if (strpos($className, $namespace) !== 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$classNames[$className] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->defaultDriver !== null) {
|
||||
foreach ($this->defaultDriver->getAllClassNames() as $className) {
|
||||
$classNames[$className] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return array_keys($classNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function isTransient(string $className)
|
||||
{
|
||||
foreach ($this->drivers as $namespace => $driver) {
|
||||
if (strpos($className, $namespace) === 0) {
|
||||
return $driver->isTransient($className);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->defaultDriver !== null) {
|
||||
return $this->defaultDriver->isTransient($className);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
47
vendor/doctrine/persistence/src/Persistence/Mapping/Driver/PHPDriver.php
vendored
Normal file
47
vendor/doctrine/persistence/src/Persistence/Mapping/Driver/PHPDriver.php
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence\Mapping\Driver;
|
||||
|
||||
use Doctrine\Persistence\Mapping\ClassMetadata;
|
||||
|
||||
/**
|
||||
* The PHPDriver includes php files which just populate ClassMetadataInfo
|
||||
* instances with plain PHP code.
|
||||
*/
|
||||
class PHPDriver extends FileDriver
|
||||
{
|
||||
/**
|
||||
* @var ClassMetadata
|
||||
* @psalm-var ClassMetadata<object>
|
||||
*/
|
||||
protected $metadata;
|
||||
|
||||
/** @param string|array<int, string>|FileLocator $locator */
|
||||
public function __construct($locator)
|
||||
{
|
||||
parent::__construct($locator, '.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function loadMetadataForClass(string $className, ClassMetadata $metadata)
|
||||
{
|
||||
$this->metadata = $metadata;
|
||||
|
||||
$this->loadMappingFile($this->locator->findMappingFile($className));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function loadMappingFile(string $file)
|
||||
{
|
||||
$metadata = $this->metadata;
|
||||
include $file;
|
||||
|
||||
return [$metadata->getName() => $metadata];
|
||||
}
|
||||
}
|
||||
132
vendor/doctrine/persistence/src/Persistence/Mapping/Driver/StaticPHPDriver.php
vendored
Normal file
132
vendor/doctrine/persistence/src/Persistence/Mapping/Driver/StaticPHPDriver.php
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence\Mapping\Driver;
|
||||
|
||||
use Doctrine\Persistence\Mapping\ClassMetadata;
|
||||
use Doctrine\Persistence\Mapping\MappingException;
|
||||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
use ReflectionClass;
|
||||
|
||||
use function array_merge;
|
||||
use function array_unique;
|
||||
use function get_declared_classes;
|
||||
use function in_array;
|
||||
use function is_dir;
|
||||
use function method_exists;
|
||||
use function realpath;
|
||||
|
||||
/**
|
||||
* The StaticPHPDriver calls a static loadMetadata() method on your entity
|
||||
* classes where you can manually populate the ClassMetadata instance.
|
||||
*/
|
||||
class StaticPHPDriver implements MappingDriver
|
||||
{
|
||||
/**
|
||||
* Paths of entity directories.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
private $paths = [];
|
||||
|
||||
/**
|
||||
* Map of all class names.
|
||||
*
|
||||
* @var array<int, string>
|
||||
* @psalm-var list<class-string>
|
||||
*/
|
||||
private $classNames;
|
||||
|
||||
/** @param array<int, string>|string $paths */
|
||||
public function __construct($paths)
|
||||
{
|
||||
$this->addPaths((array) $paths);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, string> $paths
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addPaths(array $paths)
|
||||
{
|
||||
$this->paths = array_unique(array_merge($this->paths, $paths));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function loadMetadataForClass(string $className, ClassMetadata $metadata)
|
||||
{
|
||||
$className::loadMetadata($metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @todo Same code exists in ColocatedMappingDriver, should we re-use it
|
||||
* somehow or not worry about it?
|
||||
*/
|
||||
public function getAllClassNames()
|
||||
{
|
||||
if ($this->classNames !== null) {
|
||||
return $this->classNames;
|
||||
}
|
||||
|
||||
if ($this->paths === []) {
|
||||
throw MappingException::pathRequiredForDriver(static::class);
|
||||
}
|
||||
|
||||
$classes = [];
|
||||
$includedFiles = [];
|
||||
|
||||
foreach ($this->paths as $path) {
|
||||
if (! is_dir($path)) {
|
||||
throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path);
|
||||
}
|
||||
|
||||
$iterator = new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($path),
|
||||
RecursiveIteratorIterator::LEAVES_ONLY
|
||||
);
|
||||
|
||||
foreach ($iterator as $file) {
|
||||
if ($file->getBasename('.php') === $file->getBasename()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$sourceFile = realpath($file->getPathName());
|
||||
require_once $sourceFile;
|
||||
$includedFiles[] = $sourceFile;
|
||||
}
|
||||
}
|
||||
|
||||
$declared = get_declared_classes();
|
||||
|
||||
foreach ($declared as $className) {
|
||||
$rc = new ReflectionClass($className);
|
||||
|
||||
$sourceFile = $rc->getFileName();
|
||||
|
||||
if (! in_array($sourceFile, $includedFiles, true) || $this->isTransient($className)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$classes[] = $className;
|
||||
}
|
||||
|
||||
$this->classNames = $classes;
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isTransient(string $className)
|
||||
{
|
||||
return ! method_exists($className, 'loadMetadata');
|
||||
}
|
||||
}
|
||||
265
vendor/doctrine/persistence/src/Persistence/Mapping/Driver/SymfonyFileLocator.php
vendored
Normal file
265
vendor/doctrine/persistence/src/Persistence/Mapping/Driver/SymfonyFileLocator.php
vendored
Normal file
@@ -0,0 +1,265 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence\Mapping\Driver;
|
||||
|
||||
use Doctrine\Persistence\Mapping\MappingException;
|
||||
use InvalidArgumentException;
|
||||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
use RuntimeException;
|
||||
|
||||
use function array_keys;
|
||||
use function array_merge;
|
||||
use function assert;
|
||||
use function is_dir;
|
||||
use function is_file;
|
||||
use function is_int;
|
||||
use function realpath;
|
||||
use function sprintf;
|
||||
use function str_replace;
|
||||
use function strlen;
|
||||
use function strpos;
|
||||
use function strrpos;
|
||||
use function strtr;
|
||||
use function substr;
|
||||
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
|
||||
/**
|
||||
* The Symfony File Locator makes a simplifying assumptions compared
|
||||
* to the DefaultFileLocator. By assuming paths only contain entities of a certain
|
||||
* namespace the mapping files consists of the short classname only.
|
||||
*/
|
||||
class SymfonyFileLocator implements FileLocator
|
||||
{
|
||||
/**
|
||||
* The paths where to look for mapping files.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $paths = [];
|
||||
|
||||
/**
|
||||
* A map of mapping directory path to namespace prefix used to expand class shortnames.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $prefixes = [];
|
||||
|
||||
/**
|
||||
* File extension that is searched for.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $fileExtension;
|
||||
|
||||
/**
|
||||
* Represents PHP namespace delimiters when looking for files
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $nsSeparator;
|
||||
|
||||
/**
|
||||
* @param array<string, string> $prefixes
|
||||
* @param string $nsSeparator String which would be used when converting FQCN
|
||||
* to filename and vice versa. Should not be empty
|
||||
*/
|
||||
public function __construct(
|
||||
array $prefixes,
|
||||
string $fileExtension = '',
|
||||
string $nsSeparator = '.'
|
||||
) {
|
||||
$this->addNamespacePrefixes($prefixes);
|
||||
$this->fileExtension = $fileExtension;
|
||||
|
||||
if ($nsSeparator === '') {
|
||||
throw new InvalidArgumentException('Namespace separator should not be empty');
|
||||
}
|
||||
|
||||
$this->nsSeparator = $nsSeparator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds Namespace Prefixes.
|
||||
*
|
||||
* @param array<string, string> $prefixes
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addNamespacePrefixes(array $prefixes)
|
||||
{
|
||||
$this->prefixes = array_merge($this->prefixes, $prefixes);
|
||||
$this->paths = array_merge($this->paths, array_keys($prefixes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Namespace Prefixes.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getNamespacePrefixes()
|
||||
{
|
||||
return $this->prefixes;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getPaths()
|
||||
{
|
||||
return $this->paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getFileExtension()
|
||||
{
|
||||
return $this->fileExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the file extension used to look for mapping files under.
|
||||
*
|
||||
* @param string $fileExtension The file extension to set.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setFileExtension(string $fileExtension)
|
||||
{
|
||||
$this->fileExtension = $fileExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fileExists(string $className)
|
||||
{
|
||||
$defaultFileName = str_replace('\\', $this->nsSeparator, $className) . $this->fileExtension;
|
||||
foreach ($this->paths as $path) {
|
||||
if (! isset($this->prefixes[$path])) {
|
||||
// global namespace class
|
||||
if (is_file($path . DIRECTORY_SEPARATOR . $defaultFileName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$prefix = $this->prefixes[$path];
|
||||
|
||||
if (strpos($className, $prefix . '\\') !== 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$filename = $path . '/' . strtr(substr($className, strlen($prefix) + 1), '\\', $this->nsSeparator) . $this->fileExtension;
|
||||
|
||||
if (is_file($filename)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getAllClassNames(?string $globalBasename = null)
|
||||
{
|
||||
if ($this->paths === []) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$classes = [];
|
||||
|
||||
foreach ($this->paths as $path) {
|
||||
if (! is_dir($path)) {
|
||||
throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path);
|
||||
}
|
||||
|
||||
$iterator = new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($path),
|
||||
RecursiveIteratorIterator::LEAVES_ONLY
|
||||
);
|
||||
|
||||
foreach ($iterator as $file) {
|
||||
$fileName = $file->getBasename($this->fileExtension);
|
||||
|
||||
if ($fileName === $file->getBasename() || $fileName === $globalBasename) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// NOTE: All files found here means classes are not transient!
|
||||
if (isset($this->prefixes[$path])) {
|
||||
// Calculate namespace suffix for given prefix as a relative path from basepath to file path
|
||||
$nsSuffix = strtr(
|
||||
substr($this->realpath($file->getPath()), strlen($this->realpath($path))),
|
||||
$this->nsSeparator,
|
||||
'\\'
|
||||
);
|
||||
|
||||
/** @psalm-var class-string */
|
||||
$class = $this->prefixes[$path] . str_replace(DIRECTORY_SEPARATOR, '\\', $nsSuffix) . '\\' . str_replace($this->nsSeparator, '\\', $fileName);
|
||||
} else {
|
||||
/** @psalm-var class-string */
|
||||
$class = str_replace($this->nsSeparator, '\\', $fileName);
|
||||
}
|
||||
|
||||
$classes[] = $class;
|
||||
}
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function findMappingFile(string $className)
|
||||
{
|
||||
$defaultFileName = str_replace('\\', $this->nsSeparator, $className) . $this->fileExtension;
|
||||
foreach ($this->paths as $path) {
|
||||
if (! isset($this->prefixes[$path])) {
|
||||
if (is_file($path . DIRECTORY_SEPARATOR . $defaultFileName)) {
|
||||
return $path . DIRECTORY_SEPARATOR . $defaultFileName;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$prefix = $this->prefixes[$path];
|
||||
|
||||
if (strpos($className, $prefix . '\\') !== 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$filename = $path . '/' . strtr(substr($className, strlen($prefix) + 1), '\\', $this->nsSeparator) . $this->fileExtension;
|
||||
if (is_file($filename)) {
|
||||
return $filename;
|
||||
}
|
||||
}
|
||||
|
||||
$pos = strrpos($className, '\\');
|
||||
assert(is_int($pos));
|
||||
|
||||
throw MappingException::mappingFileNotFound(
|
||||
$className,
|
||||
substr($className, $pos + 1) . $this->fileExtension
|
||||
);
|
||||
}
|
||||
|
||||
private function realpath(string $path): string
|
||||
{
|
||||
$realpath = realpath($path);
|
||||
|
||||
if ($realpath === false) {
|
||||
throw new RuntimeException(sprintf('Could not get realpath for %s', $path));
|
||||
}
|
||||
|
||||
return $realpath;
|
||||
}
|
||||
}
|
||||
88
vendor/doctrine/persistence/src/Persistence/Mapping/MappingException.php
vendored
Normal file
88
vendor/doctrine/persistence/src/Persistence/Mapping/MappingException.php
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence\Mapping;
|
||||
|
||||
use Exception;
|
||||
|
||||
use function implode;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* A MappingException indicates that something is wrong with the mapping setup.
|
||||
*/
|
||||
class MappingException extends Exception
|
||||
{
|
||||
/**
|
||||
* @param array<int, string> $namespaces
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function classNotFoundInNamespaces(
|
||||
string $className,
|
||||
array $namespaces
|
||||
) {
|
||||
return new self(sprintf(
|
||||
"The class '%s' was not found in the chain configured namespaces %s",
|
||||
$className,
|
||||
implode(', ', $namespaces)
|
||||
));
|
||||
}
|
||||
|
||||
/** @param class-string $driverClassName */
|
||||
public static function pathRequiredForDriver(string $driverClassName): self
|
||||
{
|
||||
return new self(sprintf(
|
||||
'Specifying the paths to your entities is required when using %s to retrieve all class names.',
|
||||
$driverClassName
|
||||
));
|
||||
}
|
||||
|
||||
/** @return self */
|
||||
public static function fileMappingDriversRequireConfiguredDirectoryPath(
|
||||
?string $path = null
|
||||
) {
|
||||
if ($path !== null) {
|
||||
$path = '[' . $path . ']';
|
||||
}
|
||||
|
||||
return new self(sprintf(
|
||||
'File mapping drivers must have a valid directory path, ' .
|
||||
'however the given path %s seems to be incorrect!',
|
||||
(string) $path
|
||||
));
|
||||
}
|
||||
|
||||
/** @return self */
|
||||
public static function mappingFileNotFound(string $entityName, string $fileName)
|
||||
{
|
||||
return new self(sprintf(
|
||||
"No mapping file found named '%s' for class '%s'.",
|
||||
$fileName,
|
||||
$entityName
|
||||
));
|
||||
}
|
||||
|
||||
/** @return self */
|
||||
public static function invalidMappingFile(string $entityName, string $fileName)
|
||||
{
|
||||
return new self(sprintf(
|
||||
"Invalid mapping file '%s' for class '%s'.",
|
||||
$fileName,
|
||||
$entityName
|
||||
));
|
||||
}
|
||||
|
||||
/** @return self */
|
||||
public static function nonExistingClass(string $className)
|
||||
{
|
||||
return new self(sprintf("Class '%s' does not exist", $className));
|
||||
}
|
||||
|
||||
/** @param class-string $className */
|
||||
public static function classIsAnonymous(string $className): self
|
||||
{
|
||||
return new self(sprintf('Class "%s" is anonymous', $className));
|
||||
}
|
||||
}
|
||||
19
vendor/doctrine/persistence/src/Persistence/Mapping/ProxyClassNameResolver.php
vendored
Normal file
19
vendor/doctrine/persistence/src/Persistence/Mapping/ProxyClassNameResolver.php
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence\Mapping;
|
||||
|
||||
use Doctrine\Persistence\Proxy;
|
||||
|
||||
interface ProxyClassNameResolver
|
||||
{
|
||||
/**
|
||||
* @psalm-param class-string<Proxy<T>>|class-string<T> $className
|
||||
*
|
||||
* @psalm-return class-string<T>
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
public function resolveClassName(string $className): string;
|
||||
}
|
||||
75
vendor/doctrine/persistence/src/Persistence/Mapping/ReflectionService.php
vendored
Normal file
75
vendor/doctrine/persistence/src/Persistence/Mapping/ReflectionService.php
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence\Mapping;
|
||||
|
||||
use ReflectionClass;
|
||||
use ReflectionProperty;
|
||||
|
||||
/**
|
||||
* Very simple reflection service abstraction.
|
||||
*
|
||||
* This is required inside metadata layers that may require either
|
||||
* static or runtime reflection.
|
||||
*/
|
||||
interface ReflectionService
|
||||
{
|
||||
/**
|
||||
* Returns an array of the parent classes (not interfaces) for the given class.
|
||||
*
|
||||
* @psalm-param class-string $class
|
||||
*
|
||||
* @return string[]
|
||||
* @psalm-return class-string[]
|
||||
*
|
||||
* @throws MappingException
|
||||
*/
|
||||
public function getParentClasses(string $class);
|
||||
|
||||
/**
|
||||
* Returns the shortname of a class.
|
||||
*
|
||||
* @psalm-param class-string $class
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getClassShortName(string $class);
|
||||
|
||||
/**
|
||||
* @psalm-param class-string $class
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getClassNamespace(string $class);
|
||||
|
||||
/**
|
||||
* Returns a reflection class instance or null.
|
||||
*
|
||||
* @psalm-param class-string<T> $class
|
||||
*
|
||||
* @return ReflectionClass|null
|
||||
* @psalm-return ReflectionClass<T>|null
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
public function getClass(string $class);
|
||||
|
||||
/**
|
||||
* Returns an accessible property (setAccessible(true)) or null.
|
||||
*
|
||||
* @psalm-param class-string $class
|
||||
*
|
||||
* @return ReflectionProperty|null
|
||||
*/
|
||||
public function getAccessibleProperty(string $class, string $property);
|
||||
|
||||
/**
|
||||
* Checks if the class have a public method with the given name.
|
||||
*
|
||||
* @psalm-param class-string $class
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPublicMethod(string $class, string $method);
|
||||
}
|
||||
111
vendor/doctrine/persistence/src/Persistence/Mapping/RuntimeReflectionService.php
vendored
Normal file
111
vendor/doctrine/persistence/src/Persistence/Mapping/RuntimeReflectionService.php
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence\Mapping;
|
||||
|
||||
use Doctrine\Persistence\Reflection\RuntimeReflectionProperty;
|
||||
use Doctrine\Persistence\Reflection\TypedNoDefaultReflectionProperty;
|
||||
use ReflectionClass;
|
||||
use ReflectionException;
|
||||
use ReflectionMethod;
|
||||
|
||||
use function array_key_exists;
|
||||
use function assert;
|
||||
use function class_exists;
|
||||
use function class_parents;
|
||||
use function phpversion;
|
||||
use function version_compare;
|
||||
|
||||
/**
|
||||
* PHP Runtime Reflection Service.
|
||||
*/
|
||||
class RuntimeReflectionService implements ReflectionService
|
||||
{
|
||||
/** @var bool */
|
||||
private $supportsTypedPropertiesWorkaround;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->supportsTypedPropertiesWorkaround = version_compare(phpversion(), '7.4.0') >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getParentClasses(string $class)
|
||||
{
|
||||
if (! class_exists($class)) {
|
||||
throw MappingException::nonExistingClass($class);
|
||||
}
|
||||
|
||||
$parents = class_parents($class);
|
||||
|
||||
assert($parents !== false);
|
||||
|
||||
return $parents;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getClassShortName(string $class)
|
||||
{
|
||||
$reflectionClass = new ReflectionClass($class);
|
||||
|
||||
return $reflectionClass->getShortName();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getClassNamespace(string $class)
|
||||
{
|
||||
$reflectionClass = new ReflectionClass($class);
|
||||
|
||||
return $reflectionClass->getNamespaceName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-param class-string<T> $class
|
||||
*
|
||||
* @return ReflectionClass
|
||||
* @psalm-return ReflectionClass<T>
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
public function getClass(string $class)
|
||||
{
|
||||
return new ReflectionClass($class);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getAccessibleProperty(string $class, string $property)
|
||||
{
|
||||
$reflectionProperty = new RuntimeReflectionProperty($class, $property);
|
||||
|
||||
if ($this->supportsTypedPropertiesWorkaround && ! array_key_exists($property, $this->getClass($class)->getDefaultProperties())) {
|
||||
$reflectionProperty = new TypedNoDefaultReflectionProperty($class, $property);
|
||||
}
|
||||
|
||||
$reflectionProperty->setAccessible(true);
|
||||
|
||||
return $reflectionProperty;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function hasPublicMethod(string $class, string $method)
|
||||
{
|
||||
try {
|
||||
$reflectionMethod = new ReflectionMethod($class, $method);
|
||||
} catch (ReflectionException $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $reflectionMethod->isPublic();
|
||||
}
|
||||
}
|
||||
78
vendor/doctrine/persistence/src/Persistence/Mapping/StaticReflectionService.php
vendored
Normal file
78
vendor/doctrine/persistence/src/Persistence/Mapping/StaticReflectionService.php
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence\Mapping;
|
||||
|
||||
use function strpos;
|
||||
use function strrev;
|
||||
use function strrpos;
|
||||
use function substr;
|
||||
|
||||
/**
|
||||
* PHP Runtime Reflection Service.
|
||||
*/
|
||||
class StaticReflectionService implements ReflectionService
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getParentClasses(string $class)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getClassShortName(string $class)
|
||||
{
|
||||
$nsSeparatorLastPosition = strrpos($class, '\\');
|
||||
|
||||
if ($nsSeparatorLastPosition !== false) {
|
||||
$class = substr($class, $nsSeparatorLastPosition + 1);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getClassNamespace(string $class)
|
||||
{
|
||||
$namespace = '';
|
||||
|
||||
if (strpos($class, '\\') !== false) {
|
||||
$namespace = strrev(substr(strrev($class), (int) strpos(strrev($class), '\\') + 1));
|
||||
}
|
||||
|
||||
return $namespace;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function getClass(string $class)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getAccessibleProperty(string $class, string $property)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function hasPublicMethod(string $class, string $method)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
22
vendor/doctrine/persistence/src/Persistence/NotifyPropertyChanged.php
vendored
Normal file
22
vendor/doctrine/persistence/src/Persistence/NotifyPropertyChanged.php
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence;
|
||||
|
||||
/**
|
||||
* Interface for classes that notify event listeners of changes to their managed properties.
|
||||
*
|
||||
* This interface is implemented by objects that manually want to notify their object manager or
|
||||
* other listeners when properties change, instead of relying on the object manager to compute
|
||||
* property changes itself when changes are to be persisted.
|
||||
*/
|
||||
interface NotifyPropertyChanged
|
||||
{
|
||||
/**
|
||||
* Adds a listener that wants to be notified about property changes.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addPropertyChangedListener(PropertyChangedListener $listener);
|
||||
}
|
||||
143
vendor/doctrine/persistence/src/Persistence/ObjectManager.php
vendored
Normal file
143
vendor/doctrine/persistence/src/Persistence/ObjectManager.php
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence;
|
||||
|
||||
use Doctrine\Persistence\Mapping\ClassMetadata;
|
||||
use Doctrine\Persistence\Mapping\ClassMetadataFactory;
|
||||
|
||||
/**
|
||||
* Contract for a Doctrine persistence layer ObjectManager class to implement.
|
||||
*/
|
||||
interface ObjectManager
|
||||
{
|
||||
/**
|
||||
* Finds an object by its identifier.
|
||||
*
|
||||
* This is just a convenient shortcut for getRepository($className)->find($id).
|
||||
*
|
||||
* @param string $className The class name of the object to find.
|
||||
* @param mixed $id The identity of the object to find.
|
||||
* @psalm-param class-string<T> $className
|
||||
*
|
||||
* @return object|null The found object.
|
||||
* @psalm-return T|null
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
public function find(string $className, $id);
|
||||
|
||||
/**
|
||||
* Tells the ObjectManager to make an instance managed and persistent.
|
||||
*
|
||||
* The object will be entered into the database as a result of the flush operation.
|
||||
*
|
||||
* NOTE: The persist operation always considers objects that are not yet known to
|
||||
* this ObjectManager as NEW. Do not pass detached objects to the persist operation.
|
||||
*
|
||||
* @param object $object The instance to make managed and persistent.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function persist(object $object);
|
||||
|
||||
/**
|
||||
* Removes an object instance.
|
||||
*
|
||||
* A removed object will be removed from the database as a result of the flush operation.
|
||||
*
|
||||
* @param object $object The object instance to remove.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function remove(object $object);
|
||||
|
||||
/**
|
||||
* Clears the ObjectManager. All objects that are currently managed
|
||||
* by this ObjectManager become detached.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clear();
|
||||
|
||||
/**
|
||||
* Detaches an object from the ObjectManager, causing a managed object to
|
||||
* become detached. Unflushed changes made to the object if any
|
||||
* (including removal of the object), will not be synchronized to the database.
|
||||
* Objects which previously referenced the detached object will continue to
|
||||
* reference it.
|
||||
*
|
||||
* @param object $object The object to detach.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function detach(object $object);
|
||||
|
||||
/**
|
||||
* Refreshes the persistent state of an object from the database,
|
||||
* overriding any local changes that have not yet been persisted.
|
||||
*
|
||||
* @param object $object The object to refresh.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function refresh(object $object);
|
||||
|
||||
/**
|
||||
* Flushes all changes to objects that have been queued up to now to the database.
|
||||
* This effectively synchronizes the in-memory state of managed objects with the
|
||||
* database.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function flush();
|
||||
|
||||
/**
|
||||
* Gets the repository for a class.
|
||||
*
|
||||
* @psalm-param class-string<T> $className
|
||||
*
|
||||
* @psalm-return ObjectRepository<T>
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
public function getRepository(string $className);
|
||||
|
||||
/**
|
||||
* Returns the ClassMetadata descriptor for a class.
|
||||
*
|
||||
* The class name must be the fully-qualified class name without a leading backslash
|
||||
* (as it is returned by get_class($obj)).
|
||||
*
|
||||
* @psalm-param class-string<T> $className
|
||||
*
|
||||
* @psalm-return ClassMetadata<T>
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
public function getClassMetadata(string $className);
|
||||
|
||||
/**
|
||||
* Gets the metadata factory used to gather the metadata of classes.
|
||||
*
|
||||
* @psalm-return ClassMetadataFactory<ClassMetadata<object>>
|
||||
*/
|
||||
public function getMetadataFactory();
|
||||
|
||||
/**
|
||||
* Helper method to initialize a lazy loading proxy or persistent collection.
|
||||
*
|
||||
* This method is a no-op for other objects.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initializeObject(object $obj);
|
||||
|
||||
/**
|
||||
* Checks if the object is part of the current UnitOfWork and therefore managed.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function contains(object $object);
|
||||
}
|
||||
92
vendor/doctrine/persistence/src/Persistence/ObjectManagerDecorator.php
vendored
Normal file
92
vendor/doctrine/persistence/src/Persistence/ObjectManagerDecorator.php
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence;
|
||||
|
||||
use Doctrine\Persistence\Mapping\ClassMetadata;
|
||||
use Doctrine\Persistence\Mapping\ClassMetadataFactory;
|
||||
|
||||
/**
|
||||
* Base class to simplify ObjectManager decorators
|
||||
*
|
||||
* @template-covariant TObjectManager of ObjectManager
|
||||
*/
|
||||
abstract class ObjectManagerDecorator implements ObjectManager
|
||||
{
|
||||
/** @var TObjectManager */
|
||||
protected $wrapped;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function find(string $className, $id)
|
||||
{
|
||||
return $this->wrapped->find($className, $id);
|
||||
}
|
||||
|
||||
public function persist(object $object)
|
||||
{
|
||||
$this->wrapped->persist($object);
|
||||
}
|
||||
|
||||
public function remove(object $object)
|
||||
{
|
||||
$this->wrapped->remove($object);
|
||||
}
|
||||
|
||||
public function clear(): void
|
||||
{
|
||||
$this->wrapped->clear();
|
||||
}
|
||||
|
||||
public function detach(object $object)
|
||||
{
|
||||
$this->wrapped->detach($object);
|
||||
}
|
||||
|
||||
public function refresh(object $object)
|
||||
{
|
||||
$this->wrapped->refresh($object);
|
||||
}
|
||||
|
||||
public function flush()
|
||||
{
|
||||
$this->wrapped->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRepository(string $className)
|
||||
{
|
||||
return $this->wrapped->getRepository($className);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getClassMetadata(string $className)
|
||||
{
|
||||
return $this->wrapped->getClassMetadata($className);
|
||||
}
|
||||
|
||||
/** @psalm-return ClassMetadataFactory<ClassMetadata<object>> */
|
||||
public function getMetadataFactory()
|
||||
{
|
||||
return $this->wrapped->getMetadataFactory();
|
||||
}
|
||||
|
||||
public function initializeObject(object $obj)
|
||||
{
|
||||
$this->wrapped->initializeObject($obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function contains(object $object)
|
||||
{
|
||||
return $this->wrapped->contains($object);
|
||||
}
|
||||
}
|
||||
73
vendor/doctrine/persistence/src/Persistence/ObjectRepository.php
vendored
Normal file
73
vendor/doctrine/persistence/src/Persistence/ObjectRepository.php
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence;
|
||||
|
||||
use UnexpectedValueException;
|
||||
|
||||
/**
|
||||
* Contract for a Doctrine persistence layer ObjectRepository class to implement.
|
||||
*
|
||||
* @template-covariant T of object
|
||||
*/
|
||||
interface ObjectRepository
|
||||
{
|
||||
/**
|
||||
* Finds an object by its primary key / identifier.
|
||||
*
|
||||
* @param mixed $id The identifier.
|
||||
*
|
||||
* @return object|null The object.
|
||||
* @psalm-return T|null
|
||||
*/
|
||||
public function find($id);
|
||||
|
||||
/**
|
||||
* Finds all objects in the repository.
|
||||
*
|
||||
* @return array<int, object> The objects.
|
||||
* @psalm-return T[]
|
||||
*/
|
||||
public function findAll();
|
||||
|
||||
/**
|
||||
* Finds objects by a set of criteria.
|
||||
*
|
||||
* Optionally sorting and limiting details can be passed. An implementation may throw
|
||||
* an UnexpectedValueException if certain values of the sorting or limiting details are
|
||||
* not supported.
|
||||
*
|
||||
* @param array<string, mixed> $criteria
|
||||
* @param array<string, string>|null $orderBy
|
||||
* @psalm-param array<string, 'asc'|'desc'|'ASC'|'DESC'>|null $orderBy
|
||||
*
|
||||
* @return array<int, object> The objects.
|
||||
* @psalm-return T[]
|
||||
*
|
||||
* @throws UnexpectedValueException
|
||||
*/
|
||||
public function findBy(
|
||||
array $criteria,
|
||||
?array $orderBy = null,
|
||||
?int $limit = null,
|
||||
?int $offset = null
|
||||
);
|
||||
|
||||
/**
|
||||
* Finds a single object by a set of criteria.
|
||||
*
|
||||
* @param array<string, mixed> $criteria The criteria.
|
||||
*
|
||||
* @return object|null The object.
|
||||
* @psalm-return T|null
|
||||
*/
|
||||
public function findOneBy(array $criteria);
|
||||
|
||||
/**
|
||||
* Returns the class name of the object managed by the repository.
|
||||
*
|
||||
* @psalm-return class-string<T>
|
||||
*/
|
||||
public function getClassName();
|
||||
}
|
||||
24
vendor/doctrine/persistence/src/Persistence/PropertyChangedListener.php
vendored
Normal file
24
vendor/doctrine/persistence/src/Persistence/PropertyChangedListener.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence;
|
||||
|
||||
/**
|
||||
* Contract for classes that are potential listeners of a {@see NotifyPropertyChanged}
|
||||
* implementor.
|
||||
*/
|
||||
interface PropertyChangedListener
|
||||
{
|
||||
/**
|
||||
* Collect information about a property change.
|
||||
*
|
||||
* @param object $sender The object on which the property changed.
|
||||
* @param string $propertyName The name of the property that changed.
|
||||
* @param mixed $oldValue The old value of the property that changed.
|
||||
* @param mixed $newValue The new value of the property that changed.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function propertyChanged(object $sender, string $propertyName, $oldValue, $newValue);
|
||||
}
|
||||
40
vendor/doctrine/persistence/src/Persistence/Proxy.php
vendored
Normal file
40
vendor/doctrine/persistence/src/Persistence/Proxy.php
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence;
|
||||
|
||||
/**
|
||||
* Interface for proxy classes.
|
||||
*
|
||||
* @template T of object
|
||||
* @method void __setInitialized(bool $initialized) Implementing this method will be mandatory in version 4.
|
||||
*/
|
||||
interface Proxy
|
||||
{
|
||||
/**
|
||||
* Marker for Proxy class names.
|
||||
*/
|
||||
public const MARKER = '__CG__';
|
||||
|
||||
/**
|
||||
* Length of the proxy marker.
|
||||
*/
|
||||
public const MARKER_LENGTH = 6;
|
||||
|
||||
/**
|
||||
* Initializes this proxy if its not yet initialized.
|
||||
*
|
||||
* Acts as a no-op if already initialized.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __load();
|
||||
|
||||
/**
|
||||
* Returns whether this proxy is initialized or not.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function __isInitialized();
|
||||
}
|
||||
68
vendor/doctrine/persistence/src/Persistence/Reflection/EnumReflectionProperty.php
vendored
Normal file
68
vendor/doctrine/persistence/src/Persistence/Reflection/EnumReflectionProperty.php
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence\Reflection;
|
||||
|
||||
use BackedEnum;
|
||||
use ReflectionProperty;
|
||||
use ReturnTypeWillChange;
|
||||
|
||||
/**
|
||||
* PHP Enum Reflection Property - special override for backed enums.
|
||||
*/
|
||||
class EnumReflectionProperty extends ReflectionProperty
|
||||
{
|
||||
/** @var ReflectionProperty */
|
||||
private $originalReflectionProperty;
|
||||
|
||||
/** @var class-string<BackedEnum> */
|
||||
private $enumType;
|
||||
|
||||
/** @param class-string<BackedEnum> $enumType */
|
||||
public function __construct(ReflectionProperty $originalReflectionProperty, string $enumType)
|
||||
{
|
||||
$this->originalReflectionProperty = $originalReflectionProperty;
|
||||
$this->enumType = $enumType;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* Converts enum instance to its value.
|
||||
*
|
||||
* @param object|null $object
|
||||
*
|
||||
* @return int|string|null
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function getValue($object = null)
|
||||
{
|
||||
if ($object === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$enum = $this->originalReflectionProperty->getValue($object);
|
||||
|
||||
if ($enum === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $enum->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts enum value to enum instance.
|
||||
*
|
||||
* @param object $object
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setValue($object, $value = null): void
|
||||
{
|
||||
if ($value !== null) {
|
||||
$value = $this->enumType::from($value);
|
||||
}
|
||||
|
||||
$this->originalReflectionProperty->setValue($object, $value);
|
||||
}
|
||||
}
|
||||
61
vendor/doctrine/persistence/src/Persistence/Reflection/RuntimePublicReflectionProperty.php
vendored
Normal file
61
vendor/doctrine/persistence/src/Persistence/Reflection/RuntimePublicReflectionProperty.php
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence\Reflection;
|
||||
|
||||
use Doctrine\Common\Proxy\Proxy;
|
||||
use ReflectionProperty;
|
||||
use ReturnTypeWillChange;
|
||||
|
||||
/**
|
||||
* PHP Runtime Reflection Public Property - special overrides for public properties.
|
||||
*
|
||||
* @deprecated since version 3.1, use RuntimeReflectionProperty instead.
|
||||
*/
|
||||
class RuntimePublicReflectionProperty extends ReflectionProperty
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* Returns the value of a public property without calling
|
||||
* `__get` on the provided $object if it exists.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function getValue($object = null)
|
||||
{
|
||||
return $object !== null ? ((array) $object)[$this->getName()] ?? null : parent::getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* Avoids triggering lazy loading via `__set` if the provided object
|
||||
* is a {@see \Doctrine\Common\Proxy\Proxy}.
|
||||
*
|
||||
* @link https://bugs.php.net/bug.php?id=63463
|
||||
*
|
||||
* @param object|null $object
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function setValue($object, $value = null)
|
||||
{
|
||||
if (! ($object instanceof Proxy && ! $object->__isInitialized())) {
|
||||
parent::setValue($object, $value);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$originalInitializer = $object->__getInitializer();
|
||||
$object->__setInitializer(null);
|
||||
|
||||
parent::setValue($object, $value);
|
||||
|
||||
$object->__setInitializer($originalInitializer);
|
||||
}
|
||||
}
|
||||
86
vendor/doctrine/persistence/src/Persistence/Reflection/RuntimeReflectionProperty.php
vendored
Normal file
86
vendor/doctrine/persistence/src/Persistence/Reflection/RuntimeReflectionProperty.php
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence\Reflection;
|
||||
|
||||
use Doctrine\Common\Proxy\Proxy as CommonProxy;
|
||||
use Doctrine\Persistence\Proxy;
|
||||
use ReflectionProperty;
|
||||
use ReturnTypeWillChange;
|
||||
|
||||
use function ltrim;
|
||||
use function method_exists;
|
||||
|
||||
/**
|
||||
* PHP Runtime Reflection Property.
|
||||
*
|
||||
* Avoids triggering lazy loading if the provided object
|
||||
* is a {@see \Doctrine\Persistence\Proxy}.
|
||||
*/
|
||||
class RuntimeReflectionProperty extends ReflectionProperty
|
||||
{
|
||||
/** @var string */
|
||||
private $key;
|
||||
|
||||
public function __construct(string $class, string $name)
|
||||
{
|
||||
parent::__construct($class, $name);
|
||||
|
||||
$this->key = $this->isPrivate() ? "\0" . ltrim($class, '\\') . "\0" . $name : ($this->isProtected() ? "\0*\0" . $name : $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function getValue($object = null)
|
||||
{
|
||||
if ($object === null) {
|
||||
return parent::getValue($object);
|
||||
}
|
||||
|
||||
return ((array) $object)[$this->key] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @param object|null $object
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function setValue($object, $value = null)
|
||||
{
|
||||
if (! ($object instanceof Proxy && ! $object->__isInitialized())) {
|
||||
parent::setValue($object, $value);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($object instanceof CommonProxy) {
|
||||
$originalInitializer = $object->__getInitializer();
|
||||
$object->__setInitializer(null);
|
||||
|
||||
parent::setValue($object, $value);
|
||||
|
||||
$object->__setInitializer($originalInitializer);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (! method_exists($object, '__setInitialized')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$object->__setInitialized(true);
|
||||
|
||||
parent::setValue($object, $value);
|
||||
|
||||
$object->__setInitialized(false);
|
||||
}
|
||||
}
|
||||
13
vendor/doctrine/persistence/src/Persistence/Reflection/TypedNoDefaultReflectionProperty.php
vendored
Normal file
13
vendor/doctrine/persistence/src/Persistence/Reflection/TypedNoDefaultReflectionProperty.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence\Reflection;
|
||||
|
||||
/**
|
||||
* PHP Typed No Default Reflection Property - special override for typed properties without a default value.
|
||||
*/
|
||||
class TypedNoDefaultReflectionProperty extends RuntimeReflectionProperty
|
||||
{
|
||||
use TypedNoDefaultReflectionPropertyBase;
|
||||
}
|
||||
68
vendor/doctrine/persistence/src/Persistence/Reflection/TypedNoDefaultReflectionPropertyBase.php
vendored
Normal file
68
vendor/doctrine/persistence/src/Persistence/Reflection/TypedNoDefaultReflectionPropertyBase.php
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence\Reflection;
|
||||
|
||||
use Closure;
|
||||
use ReturnTypeWillChange;
|
||||
|
||||
use function assert;
|
||||
|
||||
/**
|
||||
* PHP Typed No Default Reflection Property Base - special override for typed properties without a default value.
|
||||
*
|
||||
* @internal since version 3.1
|
||||
*/
|
||||
trait TypedNoDefaultReflectionPropertyBase
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* Checks that a typed property is initialized before accessing its value.
|
||||
* This is necessary to avoid PHP error "Error: Typed property must not be accessed before initialization".
|
||||
* Should be used only for reflecting typed properties without a default value.
|
||||
*
|
||||
* @param object|null $object
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function getValue($object = null)
|
||||
{
|
||||
return $object !== null && $this->isInitialized($object) ? parent::getValue($object) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* Works around the problem with setting typed no default properties to
|
||||
* NULL which is not supported, instead unset() to uninitialize.
|
||||
*
|
||||
* @link https://github.com/doctrine/orm/issues/7999
|
||||
*
|
||||
* @param object|null $object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function setValue($object, $value = null)
|
||||
{
|
||||
if ($value === null && $this->hasType() && ! $this->getType()->allowsNull()) {
|
||||
$propertyName = $this->getName();
|
||||
|
||||
$unsetter = function () use ($propertyName): void {
|
||||
unset($this->$propertyName);
|
||||
};
|
||||
$unsetter = $unsetter->bindTo($object, $this->getDeclaringClass()->getName());
|
||||
|
||||
assert($unsetter instanceof Closure);
|
||||
|
||||
$unsetter();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
parent::setValue($object, $value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Persistence\Reflection;
|
||||
|
||||
/**
|
||||
* PHP Typed No Default Runtime Public Reflection Property - special override for public typed properties without a default value.
|
||||
*
|
||||
* @deprecated since version 3.1, use TypedNoDefaultReflectionProperty instead.
|
||||
*/
|
||||
class TypedNoDefaultRuntimePublicReflectionProperty extends RuntimePublicReflectionProperty
|
||||
{
|
||||
use TypedNoDefaultReflectionPropertyBase;
|
||||
}
|
||||
Reference in New Issue
Block a user