default services conflit ?
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\NotifyPropertyChanged::class,
|
||||
__NAMESPACE__ . '\NotifyPropertyChanged'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
interface NotifyPropertyChanged extends \Doctrine\Persistence\NotifyPropertyChanged
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\AbstractManagerRegistry::class,
|
||||
__NAMESPACE__ . '\AbstractManagerRegistry'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
abstract class AbstractManagerRegistry extends \Doctrine\Persistence\AbstractManagerRegistry
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\ConnectionRegistry::class,
|
||||
__NAMESPACE__ . '\ConnectionRegistry'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
interface ConnectionRegistry extends \Doctrine\Persistence\ConnectionRegistry
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence\Event;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\Event\LifecycleEventArgs::class,
|
||||
__NAMESPACE__ . '\LifecycleEventArgs'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
class LifecycleEventArgs extends \Doctrine\Persistence\Event\LifecycleEventArgs
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence\Event;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\Event\LoadClassMetadataEventArgs::class,
|
||||
__NAMESPACE__ . '\LoadClassMetadataEventArgs'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
class LoadClassMetadataEventArgs extends \Doctrine\Persistence\Event\LoadClassMetadataEventArgs
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence\Event;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\Event\ManagerEventArgs::class,
|
||||
__NAMESPACE__ . '\ManagerEventArgs'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
class ManagerEventArgs extends \Doctrine\Persistence\Event\ManagerEventArgs
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence\Event;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\Event\OnClearEventArgs::class,
|
||||
__NAMESPACE__ . '\OnClearEventArgs'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
class OnClearEventArgs extends \Doctrine\Persistence\Event\OnClearEventArgs
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence\Event;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\Event\PreUpdateEventArgs::class,
|
||||
__NAMESPACE__ . '\PreUpdateEventArgs'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
class PreUpdateEventArgs extends \Doctrine\Persistence\Event\PreUpdateEventArgs
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\ManagerRegistry::class,
|
||||
__NAMESPACE__ . '\ManagerRegistry'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
interface ManagerRegistry extends \Doctrine\Persistence\ManagerRegistry
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\Mapping\AbstractClassMetadataFactory::class,
|
||||
__NAMESPACE__ . '\AbstractClassMetadataFactory'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
class AbstractClassMetadataFactory extends \Doctrine\Persistence\Mapping\AbstractClassMetadataFactory
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\Mapping\ClassMetadata::class,
|
||||
__NAMESPACE__ . '\ClassMetadata'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
interface ClassMetadata extends \Doctrine\Persistence\Mapping\ClassMetadata
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\Mapping\ClassMetadataFactory::class,
|
||||
__NAMESPACE__ . '\ClassMetadataFactory'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
interface ClassMetadataFactory extends \Doctrine\Persistence\Mapping\ClassMetadataFactory
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping\Driver;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\Mapping\Driver\AnnotationDriver::class,
|
||||
__NAMESPACE__ . '\AnnotationDriver'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
abstract class AnnotationDriver extends \Doctrine\Persistence\Mapping\Driver\AnnotationDriver
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping\Driver;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\Mapping\Driver\DefaultFileLocator::class,
|
||||
__NAMESPACE__ . '\DefaultFileLocator'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
class DefaultFileLocator extends \Doctrine\Persistence\Mapping\Driver\DefaultFileLocator
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping\Driver;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\Mapping\Driver\FileDriver::class,
|
||||
__NAMESPACE__ . '\FileDriver'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
abstract class FileDriver extends \Doctrine\Persistence\Mapping\Driver\FileDriver
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping\Driver;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\Mapping\Driver\FileLocator::class,
|
||||
__NAMESPACE__ . '\FileLocator'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
interface FileLocator extends \Doctrine\Persistence\Mapping\Driver\FileLocator
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping\Driver;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\Mapping\Driver\MappingDriver::class,
|
||||
__NAMESPACE__ . '\MappingDriver'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
interface MappingDriver extends \Doctrine\Persistence\Mapping\Driver\MappingDriver
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping\Driver;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\Mapping\Driver\MappingDriverChain::class,
|
||||
__NAMESPACE__ . '\MappingDriverChain'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
class MappingDriverChain extends \Doctrine\Persistence\Mapping\Driver\MappingDriverChain
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping\Driver;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\Mapping\Driver\PHPDriver::class,
|
||||
__NAMESPACE__ . '\PHPDriver'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
class PHPDriver extends \Doctrine\Persistence\Mapping\Driver\PHPDriver
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping\Driver;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\Mapping\Driver\StaticPHPDriver::class,
|
||||
__NAMESPACE__ . '\StaticPHPDriver'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
class StaticPHPDriver extends \Doctrine\Persistence\Mapping\Driver\StaticPHPDriver
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping\Driver;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\Mapping\Driver\SymfonyFileLocator::class,
|
||||
__NAMESPACE__ . '\SymfonyFileLocator'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
class SymfonyFileLocator extends \Doctrine\Persistence\Mapping\Driver\SymfonyFileLocator
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\Mapping\MappingException::class,
|
||||
__NAMESPACE__ . '\MappingException'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
class MappingException extends \Doctrine\Persistence\Mapping\MappingException
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\Mapping\ReflectionService::class,
|
||||
__NAMESPACE__ . '\ReflectionService'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
interface ReflectionService extends \Doctrine\Persistence\Mapping\ReflectionService
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\Mapping\RuntimeReflectionService::class,
|
||||
__NAMESPACE__ . '\RuntimeReflectionService'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
class RuntimeReflectionService extends \Doctrine\Persistence\Mapping\RuntimeReflectionService
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\Mapping\StaticReflectionService::class,
|
||||
__NAMESPACE__ . '\StaticReflectionService'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
class StaticReflectionService extends \Doctrine\Persistence\Mapping\StaticReflectionService
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\ObjectManager::class,
|
||||
__NAMESPACE__ . '\ObjectManager'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
interface ObjectManager extends \Doctrine\Persistence\ObjectManager
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\ObjectManagerAware::class,
|
||||
__NAMESPACE__ . '\ObjectManagerAware'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
interface ObjectManagerAware extends \Doctrine\Persistence\ObjectManagerAware
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\ObjectManagerDecorator::class,
|
||||
__NAMESPACE__ . '\ObjectManagerDecorator'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
abstract class ObjectManagerDecorator extends \Doctrine\Persistence\ObjectManagerDecorator
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\ObjectRepository::class,
|
||||
__NAMESPACE__ . '\ObjectRepository'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
interface ObjectRepository extends \Doctrine\Persistence\ObjectRepository
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,235 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence;
|
||||
|
||||
use BadMethodCallException;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Persistence\Mapping\ClassMetadata;
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
use function class_exists;
|
||||
use function lcfirst;
|
||||
use function substr;
|
||||
|
||||
/**
|
||||
* PersistentObject base class that implements getter/setter methods for all mapped fields and associations
|
||||
* by overriding __call.
|
||||
*
|
||||
* This class is a forward compatible implementation of the PersistentObject trait.
|
||||
*
|
||||
* Limitations:
|
||||
*
|
||||
* 1. All persistent objects have to be associated with a single ObjectManager, multiple
|
||||
* ObjectManagers are not supported. You can set the ObjectManager with `PersistentObject#setObjectManager()`.
|
||||
* 2. Setters and getters only work if a ClassMetadata instance was injected into the PersistentObject.
|
||||
* This is either done on `postLoad` of an object or by accessing the global object manager.
|
||||
* 3. There are no hooks for setters/getters. Just implement the method yourself instead of relying on __call().
|
||||
* 4. Slower than handcoded implementations: An average of 7 method calls per access to a field and 11 for an association.
|
||||
* 5. Only the inverse side associations get autoset on the owning side as well. Setting objects on the owning side
|
||||
* will not set the inverse side associations.
|
||||
*
|
||||
* @deprecated Deprecated `PersistentObject` class in 1.2. Please implement this functionality
|
||||
* directly in your application if you want ActiveRecord style functionality.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* PersistentObject::setObjectManager($em);
|
||||
*
|
||||
* class Foo extends PersistentObject
|
||||
* {
|
||||
* private $id;
|
||||
* }
|
||||
*
|
||||
* $foo = new Foo();
|
||||
* $foo->getId(); // method exists through __call
|
||||
*/
|
||||
abstract class PersistentObject implements ObjectManagerAware
|
||||
{
|
||||
/** @var ObjectManager|null */
|
||||
private static $objectManager = null;
|
||||
|
||||
/** @var ClassMetadata|null */
|
||||
private $cm = null;
|
||||
|
||||
/**
|
||||
* Sets the object manager responsible for all persistent object base classes.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function setObjectManager(?ObjectManager $objectManager = null)
|
||||
{
|
||||
self::$objectManager = $objectManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ObjectManager|null
|
||||
*/
|
||||
public static function getObjectManager()
|
||||
{
|
||||
return self::$objectManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Injects the Doctrine Object Manager.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function injectObjectManager(ObjectManager $objectManager, ClassMetadata $classMetadata)
|
||||
{
|
||||
if ($objectManager !== self::$objectManager) {
|
||||
throw new RuntimeException('Trying to use PersistentObject with different ObjectManager instances. ' .
|
||||
'Was PersistentObject::setObjectManager() called?');
|
||||
}
|
||||
|
||||
$this->cm = $classMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a persistent fields value.
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed[] $args
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws BadMethodCallException When no persistent field exists by that name.
|
||||
* @throws InvalidArgumentException When the wrong target object type is passed to an association.
|
||||
*/
|
||||
private function set($field, $args)
|
||||
{
|
||||
if ($this->cm->hasField($field) && ! $this->cm->isIdentifier($field)) {
|
||||
$this->$field = $args[0];
|
||||
} elseif ($this->cm->hasAssociation($field) && $this->cm->isSingleValuedAssociation($field)) {
|
||||
$targetClass = $this->cm->getAssociationTargetClass($field);
|
||||
if (! ($args[0] instanceof $targetClass) && $args[0] !== null) {
|
||||
throw new InvalidArgumentException("Expected persistent object of type '" . $targetClass . "'");
|
||||
}
|
||||
$this->$field = $args[0];
|
||||
$this->completeOwningSide($field, $targetClass, $args[0]);
|
||||
} else {
|
||||
throw new BadMethodCallException("no field with name '" . $field . "' exists on '" . $this->cm->getName() . "'");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a persistent field value.
|
||||
*
|
||||
* @param string $field
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws BadMethodCallException When no persistent field exists by that name.
|
||||
*/
|
||||
private function get($field)
|
||||
{
|
||||
if ($this->cm->hasField($field) || $this->cm->hasAssociation($field)) {
|
||||
return $this->$field;
|
||||
}
|
||||
|
||||
throw new BadMethodCallException("no field with name '" . $field . "' exists on '" . $this->cm->getName() . "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* If this is an inverse side association, completes the owning side.
|
||||
*
|
||||
* @param string $field
|
||||
* @param ClassMetadata $targetClass
|
||||
* @param object $targetObject
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function completeOwningSide($field, $targetClass, $targetObject)
|
||||
{
|
||||
// add this object on the owning side as well, for obvious infinite recursion
|
||||
// reasons this is only done when called on the inverse side.
|
||||
if (! $this->cm->isAssociationInverseSide($field)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$mappedByField = $this->cm->getAssociationMappedByTargetField($field);
|
||||
$targetMetadata = self::$objectManager->getClassMetadata($targetClass);
|
||||
|
||||
$setter = ($targetMetadata->isCollectionValuedAssociation($mappedByField) ? 'add' : 'set') . $mappedByField;
|
||||
$targetObject->$setter($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an object to a collection.
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed[] $args
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws BadMethodCallException
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
private function add($field, $args)
|
||||
{
|
||||
if (! $this->cm->hasAssociation($field) || ! $this->cm->isCollectionValuedAssociation($field)) {
|
||||
throw new BadMethodCallException('There is no method add' . $field . '() on ' . $this->cm->getName());
|
||||
}
|
||||
|
||||
$targetClass = $this->cm->getAssociationTargetClass($field);
|
||||
if (! ($args[0] instanceof $targetClass)) {
|
||||
throw new InvalidArgumentException("Expected persistent object of type '" . $targetClass . "'");
|
||||
}
|
||||
if (! ($this->$field instanceof Collection)) {
|
||||
$this->$field = new ArrayCollection($this->$field ?: []);
|
||||
}
|
||||
$this->$field->add($args[0]);
|
||||
$this->completeOwningSide($field, $targetClass, $args[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes Doctrine Metadata for this class.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
private function initializeDoctrine()
|
||||
{
|
||||
if ($this->cm !== null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (! self::$objectManager) {
|
||||
throw new RuntimeException('No runtime object manager set. Call PersistentObject#setObjectManager().');
|
||||
}
|
||||
|
||||
$this->cm = self::$objectManager->getClassMetadata(static::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic methods.
|
||||
*
|
||||
* @param string $method
|
||||
* @param mixed[] $args
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws BadMethodCallException
|
||||
*/
|
||||
public function __call($method, $args)
|
||||
{
|
||||
$this->initializeDoctrine();
|
||||
|
||||
$command = substr($method, 0, 3);
|
||||
$field = lcfirst(substr($method, 3));
|
||||
if ($command === 'set') {
|
||||
$this->set($field, $args);
|
||||
} elseif ($command === 'get') {
|
||||
return $this->get($field);
|
||||
} elseif ($command === 'add') {
|
||||
$this->add($field, $args);
|
||||
} else {
|
||||
throw new BadMethodCallException('There is no method ' . $method . ' on ' . $this->cm->getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class_exists(\Doctrine\Common\Persistence\PersistentObject::class);
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Persistence;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\Proxy::class,
|
||||
__NAMESPACE__ . '\Proxy'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
interface Proxy extends \Doctrine\Persistence\Proxy
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common;
|
||||
|
||||
use function class_alias;
|
||||
|
||||
class_alias(
|
||||
\Doctrine\Persistence\PropertyChangedListener::class,
|
||||
__NAMESPACE__ . '\PropertyChangedListener'
|
||||
);
|
||||
|
||||
if (false) {
|
||||
interface PropertyChangedListener extends \Doctrine\Persistence\PropertyChangedListener
|
||||
{
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user