forked from lino/radar-wp
Initial import.
This commit is contained in:
commit
86383280c9
428 changed files with 68738 additions and 0 deletions
259
vendor/doctrine/common/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php
vendored
Normal file
259
vendor/doctrine/common/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php
vendored
Normal file
|
@ -0,0 +1,259 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence;
|
||||
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* Abstract implementation of the ManagerRegistry contract.
|
||||
*
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.2
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Lukas Kahwe Smith <smith@pooteeweet.org>
|
||||
*/
|
||||
abstract class AbstractManagerRegistry implements ManagerRegistry
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $connections;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $managers;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $defaultConnection;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $defaultManager;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $proxyInterfaceName;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $connections
|
||||
* @param array $managers
|
||||
* @param string $defaultConnection
|
||||
* @param string $defaultManager
|
||||
* @param string $proxyInterfaceName
|
||||
*/
|
||||
public function __construct($name, array $connections, array $managers, $defaultConnection, $defaultManager, $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 name of the service
|
||||
* @return object instance of the given service
|
||||
*/
|
||||
abstract protected function getService($name);
|
||||
|
||||
/**
|
||||
* Resets the given services
|
||||
*
|
||||
* A service in this context is connection or a manager instance
|
||||
*
|
||||
* @param string $name name of the service
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function resetService($name);
|
||||
|
||||
/**
|
||||
* Get the name of the registry
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getConnection($name = null)
|
||||
{
|
||||
if (null === $name) {
|
||||
$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 = array();
|
||||
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($name = null)
|
||||
{
|
||||
if (null === $name) {
|
||||
$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($class)
|
||||
{
|
||||
// Check for namespace alias
|
||||
if (strpos($class, ':') !== false) {
|
||||
list($namespaceAlias, $simpleClassName) = explode(':', $class);
|
||||
$class = $this->getAliasNamespace($namespaceAlias) . '\\' . $simpleClassName;
|
||||
}
|
||||
|
||||
$proxyClass = new \ReflectionClass($class);
|
||||
if ($proxyClass->implementsInterface($this->proxyInterfaceName)) {
|
||||
$class = $proxyClass->getParentClass()->getName();
|
||||
}
|
||||
|
||||
foreach ($this->managers as $id) {
|
||||
$manager = $this->getService($id);
|
||||
|
||||
if (!$manager->getMetadataFactory()->isTransient($class)) {
|
||||
return $manager;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getManagerNames()
|
||||
{
|
||||
return $this->managers;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getManagers()
|
||||
{
|
||||
$dms = array();
|
||||
foreach ($this->managers as $name => $id) {
|
||||
$dms[$name] = $this->getService($id);
|
||||
}
|
||||
|
||||
return $dms;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRepository($persistentObjectName, $persistentManagerName = null)
|
||||
{
|
||||
return $this->getManager($persistentManagerName)->getRepository($persistentObjectName);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function resetManager($name = null)
|
||||
{
|
||||
if (null === $name) {
|
||||
$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]);
|
||||
}
|
||||
}
|
63
vendor/doctrine/common/lib/Doctrine/Common/Persistence/ConnectionRegistry.php
vendored
Normal file
63
vendor/doctrine/common/lib/Doctrine/Common/Persistence/ConnectionRegistry.php
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence;
|
||||
|
||||
/**
|
||||
* Contract covering connection for a Doctrine persistence layer ManagerRegistry class to implement.
|
||||
*
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.2
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Lukas Kahwe Smith <smith@pooteeweet.org>
|
||||
*/
|
||||
interface ConnectionRegistry
|
||||
{
|
||||
/**
|
||||
* Gets the default connection name.
|
||||
*
|
||||
* @return string The default connection name
|
||||
*/
|
||||
function getDefaultConnectionName();
|
||||
|
||||
/**
|
||||
* Gets the named connection.
|
||||
*
|
||||
* @param string $name The connection name (null for the default one)
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
function getConnection($name = null);
|
||||
|
||||
/**
|
||||
* Gets an array of all registered connections
|
||||
*
|
||||
* @return array An array of Connection instances
|
||||
*/
|
||||
function getConnections();
|
||||
|
||||
/**
|
||||
* Gets all connection names.
|
||||
*
|
||||
* @return array An array of connection names
|
||||
*/
|
||||
function getConnectionNames();
|
||||
}
|
77
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/LifecycleEventArgs.php
vendored
Normal file
77
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/LifecycleEventArgs.php
vendored
Normal file
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence\Event;
|
||||
|
||||
use Doctrine\Common\EventArgs;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
|
||||
/**
|
||||
* Lifecycle Events are triggered by the UnitOfWork during lifecycle transitions
|
||||
* of entities.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.2
|
||||
* @author Roman Borschel <roman@code-factory.de>
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
class LifecycleEventArgs extends EventArgs
|
||||
{
|
||||
/**
|
||||
* @var ObjectManager
|
||||
*/
|
||||
private $objectManager;
|
||||
|
||||
/**
|
||||
* @var object
|
||||
*/
|
||||
private $entity;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param object $entity
|
||||
* @param ObjectManager $objectManager
|
||||
*/
|
||||
public function __construct($entity, ObjectManager $objectManager)
|
||||
{
|
||||
$this->entity = $entity;
|
||||
$this->objectManager = $objectManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve associated Entity.
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function getEntity()
|
||||
{
|
||||
return $this->entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve associated ObjectManager.
|
||||
*
|
||||
* @return ObjectManager
|
||||
*/
|
||||
public function getObjectManager()
|
||||
{
|
||||
return $this->objectManager;
|
||||
}
|
||||
}
|
76
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/LoadClassMetadataEventArgs.php
vendored
Normal file
76
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/LoadClassMetadataEventArgs.php
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence\Event;
|
||||
|
||||
use Doctrine\Common\EventArgs;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
|
||||
|
||||
/**
|
||||
* Class that holds event arguments for a loadMetadata event.
|
||||
*
|
||||
* @author Jonathan H. Wage <jonwage@gmail.com>
|
||||
* @since 2.2
|
||||
*/
|
||||
class LoadClassMetadataEventArgs extends EventArgs
|
||||
{
|
||||
/**
|
||||
* @var ClassMetadata
|
||||
*/
|
||||
private $classMetadata;
|
||||
|
||||
/**
|
||||
* @var ObjectManager
|
||||
*/
|
||||
private $objectManager;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param ClassMetadata $classMetadata
|
||||
* @param ObjectManager $objectManager
|
||||
*/
|
||||
public function __construct(ClassMetadata $classMetadata, ObjectManager $objectManager)
|
||||
{
|
||||
$this->classMetadata = $classMetadata;
|
||||
$this->objectManager = $objectManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve associated ClassMetadata.
|
||||
*
|
||||
* @return ClassMetadata
|
||||
*/
|
||||
public function getClassMetadata()
|
||||
{
|
||||
return $this->classMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve associated ObjectManager.
|
||||
*
|
||||
* @return ObjectManager
|
||||
*/
|
||||
public function getObjectManager()
|
||||
{
|
||||
return $this->objectManager;
|
||||
}
|
||||
}
|
||||
|
59
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/ManagerEventArgs.php
vendored
Normal file
59
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/ManagerEventArgs.php
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence\Event;
|
||||
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
|
||||
/**
|
||||
* Provides event arguments for the preFlush event.
|
||||
*
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.2
|
||||
* @author Roman Borschel <roman@code-factory.de>
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
class ManagerEventArgs extends \Doctrine\Common\EventArgs
|
||||
{
|
||||
/**
|
||||
* @var ObjectManager
|
||||
*/
|
||||
private $objectManager;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param ObjectManager $objectManager
|
||||
*/
|
||||
public function __construct(ObjectManager $objectManager)
|
||||
{
|
||||
$this->objectManager = $objectManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve associated ObjectManager.
|
||||
*
|
||||
* @return ObjectManager
|
||||
*/
|
||||
public function getObjectManager()
|
||||
{
|
||||
return $this->objectManager;
|
||||
}
|
||||
}
|
84
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/OnClearEventArgs.php
vendored
Normal file
84
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/OnClearEventArgs.php
vendored
Normal file
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence\Event;
|
||||
|
||||
/**
|
||||
* Provides event arguments for the onClear event.
|
||||
*
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.2
|
||||
* @author Roman Borschel <roman@code-factory.de>
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
class OnClearEventArgs extends \Doctrine\Common\EventArgs
|
||||
{
|
||||
/**
|
||||
* @var \Doctrine\Common\Persistence\ObjectManager
|
||||
*/
|
||||
private $objectManager;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $entityClass;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param \Doctrine\Common\Persistence\ObjectManager $objectManager
|
||||
* @param string $entityClass Optional entity class
|
||||
*/
|
||||
public function __construct($objectManager, $entityClass = null)
|
||||
{
|
||||
$this->objectManager = $objectManager;
|
||||
$this->entityClass = $entityClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve associated ObjectManager.
|
||||
*
|
||||
* @return \Doctrine\Common\Persistence\ObjectManager
|
||||
*/
|
||||
public function getObjectManager()
|
||||
{
|
||||
return $this->objectManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Name of the entity class that is cleared, or empty if all are cleared.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEntityClass()
|
||||
{
|
||||
return $this->entityClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if event clears all entities.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function clearsAllEntities()
|
||||
{
|
||||
return ($this->entityClass === null);
|
||||
}
|
||||
}
|
133
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/PreUpdateEventArgs.php
vendored
Normal file
133
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Event/PreUpdateEventArgs.php
vendored
Normal file
|
@ -0,0 +1,133 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence\Event;
|
||||
|
||||
use Doctrine\Common\EventArgs,
|
||||
Doctrine\Common\Persistence\ObjectManager;
|
||||
|
||||
/**
|
||||
* Class that holds event arguments for a preUpdate event.
|
||||
*
|
||||
* @author Guilherme Blanco <guilehrmeblanco@hotmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @since 2.2
|
||||
*/
|
||||
class PreUpdateEventArgs extends LifecycleEventArgs
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $entityChangeSet;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param object $entity
|
||||
* @param ObjectManager $objectManager
|
||||
* @param array $changeSet
|
||||
*/
|
||||
public function __construct($entity, ObjectManager $objectManager, array &$changeSet)
|
||||
{
|
||||
parent::__construct($entity, $objectManager);
|
||||
|
||||
$this->entityChangeSet = &$changeSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve entity changeset.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getEntityChangeSet()
|
||||
{
|
||||
return $this->entityChangeSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if field has a changeset.
|
||||
*
|
||||
* @param string $field
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasChangedField($field)
|
||||
{
|
||||
return isset($this->entityChangeSet[$field]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the old value of the changeset of the changed field.
|
||||
*
|
||||
* @param string $field
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOldValue($field)
|
||||
{
|
||||
$this->assertValidField($field);
|
||||
|
||||
return $this->entityChangeSet[$field][0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the new value of the changeset of the changed field.
|
||||
*
|
||||
* @param string $field
|
||||
* @return mixed
|
||||
*/
|
||||
public function getNewValue($field)
|
||||
{
|
||||
$this->assertValidField($field);
|
||||
|
||||
return $this->entityChangeSet[$field][1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the new value of this field.
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setNewValue($field, $value)
|
||||
{
|
||||
$this->assertValidField($field);
|
||||
|
||||
$this->entityChangeSet[$field][1] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert the field exists in changeset.
|
||||
*
|
||||
* @param string $field
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
private function assertValidField($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->getEntity())
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
112
vendor/doctrine/common/lib/Doctrine/Common/Persistence/ManagerRegistry.php
vendored
Normal file
112
vendor/doctrine/common/lib/Doctrine/Common/Persistence/ManagerRegistry.php
vendored
Normal file
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence;
|
||||
|
||||
/**
|
||||
* Contract covering object managers for a Doctrine persistence layer ManagerRegistry class to implement.
|
||||
*
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.2
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Lukas Kahwe Smith <smith@pooteeweet.org>
|
||||
*/
|
||||
interface ManagerRegistry extends ConnectionRegistry
|
||||
{
|
||||
/**
|
||||
* Gets the default object manager name.
|
||||
*
|
||||
* @return string The default object manager name
|
||||
*/
|
||||
function getDefaultManagerName();
|
||||
|
||||
/**
|
||||
* Gets a named object manager.
|
||||
*
|
||||
* @param string $name The object manager name (null for the default one)
|
||||
*
|
||||
* @return \Doctrine\Common\Persistence\ObjectManager
|
||||
*/
|
||||
function getManager($name = null);
|
||||
|
||||
/**
|
||||
* Gets an array of all registered object managers
|
||||
*
|
||||
* @return \Doctrine\Common\Persistence\ObjectManager[] An array of ObjectManager instances
|
||||
*/
|
||||
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 $name The object manager name (null for the default one)
|
||||
*
|
||||
* @return \Doctrine\Common\Persistence\ObjectManager
|
||||
*/
|
||||
function resetManager($name = null);
|
||||
|
||||
/**
|
||||
* Resolves a registered namespace alias to the full namespace.
|
||||
*
|
||||
* This method looks for the alias in all registered object managers.
|
||||
*
|
||||
* @param string $alias The alias
|
||||
*
|
||||
* @return string The full namespace
|
||||
*/
|
||||
function getAliasNamespace($alias);
|
||||
|
||||
/**
|
||||
* Gets all connection names.
|
||||
*
|
||||
* @return array An array of connection names
|
||||
*/
|
||||
function getManagerNames();
|
||||
|
||||
/**
|
||||
* Gets the ObjectRepository for an persistent object.
|
||||
*
|
||||
* @param string $persistentObject The name of the persistent object.
|
||||
* @param string $persistentManagerName The object manager name (null for the default one)
|
||||
*
|
||||
* @return \Doctrine\Common\Persistence\ObjectRepository
|
||||
*/
|
||||
function getRepository($persistentObject, $persistentManagerName = null);
|
||||
|
||||
/**
|
||||
* Gets the object manager associated with a given class.
|
||||
*
|
||||
* @param string $class A persistent object class name
|
||||
*
|
||||
* @return \Doctrine\Common\Persistence\ObjectManager|null
|
||||
*/
|
||||
function getManagerForClass($class);
|
||||
}
|
383
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php
vendored
Normal file
383
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php
vendored
Normal file
|
@ -0,0 +1,383 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping;
|
||||
|
||||
use Doctrine\Common\Cache\Cache,
|
||||
Doctrine\Common\Util\ClassUtils;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @since 2.2
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
*/
|
||||
abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
||||
{
|
||||
/**
|
||||
* Salt used by specific Object Manager implementation.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $cacheSalt = "\$CLASSMETADATA";
|
||||
|
||||
/**
|
||||
* @var \Doctrine\Common\Cache\Cache
|
||||
*/
|
||||
private $cacheDriver;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $loadedMetadata = array();
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $initialized = false;
|
||||
|
||||
/**
|
||||
* @var ReflectionService
|
||||
*/
|
||||
private $reflectionService;
|
||||
|
||||
/**
|
||||
* Sets the cache driver used by the factory to cache ClassMetadata instances.
|
||||
*
|
||||
* @param Doctrine\Common\Cache\Cache $cacheDriver
|
||||
*/
|
||||
public function setCacheDriver(Cache $cacheDriver = null)
|
||||
{
|
||||
$this->cacheDriver = $cacheDriver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cache driver used by the factory to cache ClassMetadata instances.
|
||||
*
|
||||
* @return Doctrine\Common\Cache\Cache
|
||||
*/
|
||||
public function getCacheDriver()
|
||||
{
|
||||
return $this->cacheDriver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of all the loaded metadata currently in memory.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getLoadedMetadata()
|
||||
{
|
||||
return $this->loadedMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces the factory to load the metadata of all classes known to the underlying
|
||||
* mapping driver.
|
||||
*
|
||||
* @return array The ClassMetadata instances of all mapped classes.
|
||||
*/
|
||||
public function getAllMetadata()
|
||||
{
|
||||
if ( ! $this->initialized) {
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
$driver = $this->getDriver();
|
||||
$metadata = array();
|
||||
foreach ($driver->getAllClassNames() as $className) {
|
||||
$metadata[] = $this->getMetadataFor($className);
|
||||
}
|
||||
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* Get the fully qualified class-name from the namespace alias.
|
||||
*
|
||||
* @param string $namespaceAlias
|
||||
* @param string $simpleClassName
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getFqcnFromAlias($namespaceAlias, $simpleClassName);
|
||||
|
||||
/**
|
||||
* Return the mapping driver implementation.
|
||||
*
|
||||
* @return \Doctrine\Common\Persistence\Mapping\Driver\MappingDriver
|
||||
*/
|
||||
abstract protected function getDriver();
|
||||
|
||||
/**
|
||||
* Wakeup reflection after ClassMetadata gets unserialized from cache.
|
||||
*
|
||||
* @param ClassMetadata $class
|
||||
* @param ReflectionService $reflService
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function wakeupReflection(ClassMetadata $class, ReflectionService $reflService);
|
||||
|
||||
/**
|
||||
* Initialize Reflection after ClassMetadata was constructed.
|
||||
*
|
||||
* @param ClassMetadata $class
|
||||
* @param ReflectionService $reflService
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function initializeReflection(ClassMetadata $class, ReflectionService $reflService);
|
||||
|
||||
/**
|
||||
* Checks whether the class metadata is an entity.
|
||||
*
|
||||
* This method should false for mapped superclasses or
|
||||
* embedded classes.
|
||||
*
|
||||
* @param ClassMetadata $class
|
||||
* @return boolean
|
||||
*/
|
||||
abstract protected function isEntity(ClassMetadata $class);
|
||||
|
||||
/**
|
||||
* Gets the class metadata descriptor for a class.
|
||||
*
|
||||
* @param string $className The name of the class.
|
||||
* @return \Doctrine\Common\Persistence\Mapping\ClassMetadata
|
||||
*/
|
||||
public function getMetadataFor($className)
|
||||
{
|
||||
if (isset($this->loadedMetadata[$className])) {
|
||||
return $this->loadedMetadata[$className];
|
||||
}
|
||||
|
||||
$realClassName = $className;
|
||||
|
||||
// Check for namespace alias
|
||||
if (strpos($className, ':') !== false) {
|
||||
list($namespaceAlias, $simpleClassName) = explode(':', $className);
|
||||
$realClassName = $this->getFqcnFromAlias($namespaceAlias, $simpleClassName);
|
||||
} else {
|
||||
$realClassName = ClassUtils::getRealClass($realClassName);
|
||||
}
|
||||
|
||||
if (isset($this->loadedMetadata[$realClassName])) {
|
||||
// We do not have the alias name in the map, include it
|
||||
$this->loadedMetadata[$className] = $this->loadedMetadata[$realClassName];
|
||||
|
||||
return $this->loadedMetadata[$realClassName];
|
||||
}
|
||||
|
||||
if ($this->cacheDriver) {
|
||||
if (($cached = $this->cacheDriver->fetch($realClassName . $this->cacheSalt)) !== false) {
|
||||
$this->loadedMetadata[$realClassName] = $cached;
|
||||
$this->wakeupReflection($cached, $this->getReflectionService());
|
||||
} else {
|
||||
foreach ($this->loadMetadata($realClassName) as $loadedClassName) {
|
||||
$this->cacheDriver->save(
|
||||
$loadedClassName . $this->cacheSalt, $this->loadedMetadata[$loadedClassName], null
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->loadMetadata($realClassName);
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the factory has the metadata for a class loaded already.
|
||||
*
|
||||
* @param string $className
|
||||
* @return boolean TRUE if the metadata of the class in question is already loaded, FALSE otherwise.
|
||||
*/
|
||||
public function hasMetadataFor($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.
|
||||
*
|
||||
* @param string $className
|
||||
* @param ClassMetadata $class
|
||||
*/
|
||||
public function setMetadataFor($className, $class)
|
||||
{
|
||||
$this->loadedMetadata[$className] = $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array of parent classes for the given entity class
|
||||
*
|
||||
* @param string $name
|
||||
* @return array $parentClasses
|
||||
*/
|
||||
protected function getParentClasses($name)
|
||||
{
|
||||
// Collect parent classes, ignoring transient (not-mapped) classes.
|
||||
$parentClasses = array();
|
||||
foreach (array_reverse($this->getReflectionService()->getParentClasses($name)) as $parentClass) {
|
||||
if ( ! $this->getDriver()->isTransient($parentClass)) {
|
||||
$parentClasses[] = $parentClass;
|
||||
}
|
||||
}
|
||||
return $parentClasses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the metadata of the class in question and all it's ancestors whose metadata
|
||||
* is still not loaded.
|
||||
*
|
||||
* @param string $name The name of the class for which the metadata should get loaded.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function loadMetadata($name)
|
||||
{
|
||||
if ( ! $this->initialized) {
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
$loaded = array();
|
||||
|
||||
$parentClasses = $this->getParentClasses($name);
|
||||
$parentClasses[] = $name;
|
||||
|
||||
// Move down the hierarchy of parent classes, starting from the topmost class
|
||||
$parent = null;
|
||||
$rootEntityFound = false;
|
||||
$visited = array();
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Actually load the metadata from the underlying metadata
|
||||
*
|
||||
* @param ClassMetadata $class
|
||||
* @param ClassMetadata|null $parent
|
||||
* @param bool $rootEntityFound
|
||||
* @param array $nonSuperclassParents classnames all parent classes that are not marked as mapped superclasses
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function doLoadMetadata($class, $parent, $rootEntityFound, array $nonSuperclassParents);
|
||||
|
||||
/**
|
||||
* Creates a new ClassMetadata instance for the given class name.
|
||||
*
|
||||
* @param string $className
|
||||
* @return ClassMetadata
|
||||
*/
|
||||
abstract protected function newClassMetadataInstance($className);
|
||||
|
||||
/**
|
||||
* Check if this class is mapped by this Object Manager + ClassMetadata configuration
|
||||
*
|
||||
* @param $class
|
||||
* @return bool
|
||||
*/
|
||||
public function isTransient($class)
|
||||
{
|
||||
if ( ! $this->initialized) {
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
// Check for namespace alias
|
||||
if (strpos($class, ':') !== false) {
|
||||
list($namespaceAlias, $simpleClassName) = explode(':', $class);
|
||||
$class = $this->getFqcnFromAlias($namespaceAlias, $simpleClassName);
|
||||
}
|
||||
|
||||
return $this->getDriver()->isTransient($class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set reflectionService.
|
||||
*
|
||||
* @param ReflectionService $reflectionService
|
||||
*/
|
||||
public function setReflectionService(ReflectionService $reflectionService)
|
||||
{
|
||||
$this->reflectionService = $reflectionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the reflection service associated with this metadata factory.
|
||||
*
|
||||
* @return ReflectionService
|
||||
*/
|
||||
public function getReflectionService()
|
||||
{
|
||||
if ($this->reflectionService === null) {
|
||||
$this->reflectionService = new RuntimeReflectionService();
|
||||
}
|
||||
return $this->reflectionService;
|
||||
}
|
||||
}
|
165
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/ClassMetadata.php
vendored
Normal file
165
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/ClassMetadata.php
vendored
Normal file
|
@ -0,0 +1,165 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping;
|
||||
|
||||
/**
|
||||
* Contract for a Doctrine persistence layer ClassMetadata class to implement.
|
||||
*
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.1
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
*/
|
||||
interface ClassMetadata
|
||||
{
|
||||
/**
|
||||
* Get fully-qualified class name of this persistent class.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getName();
|
||||
|
||||
/**
|
||||
* Gets the mapped identifier field name.
|
||||
*
|
||||
* The returned structure is an array of the identifier field names.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getIdentifier();
|
||||
|
||||
/**
|
||||
* Gets the ReflectionClass instance for this mapped class.
|
||||
*
|
||||
* @return \ReflectionClass
|
||||
*/
|
||||
function getReflectionClass();
|
||||
|
||||
/**
|
||||
* Checks if the given field name is a mapped identifier for this class.
|
||||
*
|
||||
* @param string $fieldName
|
||||
* @return boolean
|
||||
*/
|
||||
function isIdentifier($fieldName);
|
||||
|
||||
/**
|
||||
* Checks if the given field is a mapped property for this class.
|
||||
*
|
||||
* @param string $fieldName
|
||||
* @return boolean
|
||||
*/
|
||||
function hasField($fieldName);
|
||||
|
||||
/**
|
||||
* Checks if the given field is a mapped association for this class.
|
||||
*
|
||||
* @param string $fieldName
|
||||
* @return boolean
|
||||
*/
|
||||
function hasAssociation($fieldName);
|
||||
|
||||
/**
|
||||
* Checks if the given field is a mapped single valued association for this class.
|
||||
*
|
||||
* @param string $fieldName
|
||||
* @return boolean
|
||||
*/
|
||||
function isSingleValuedAssociation($fieldName);
|
||||
|
||||
/**
|
||||
* Checks if the given field is a mapped collection valued association for this class.
|
||||
*
|
||||
* @param string $fieldName
|
||||
* @return boolean
|
||||
*/
|
||||
function isCollectionValuedAssociation($fieldName);
|
||||
|
||||
/**
|
||||
* A numerically indexed list of field names of this persistent class.
|
||||
*
|
||||
* This array includes identifier fields if present on this class.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getFieldNames();
|
||||
|
||||
/**
|
||||
* Returns an array of identifier field names numerically indexed.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getIdentifierFieldNames();
|
||||
|
||||
/**
|
||||
* A numerically indexed list of association names of this persistent class.
|
||||
*
|
||||
* This array includes identifier associations if present on this class.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param string $fieldName
|
||||
* @return string
|
||||
*/
|
||||
function getTypeOfField($fieldName);
|
||||
|
||||
/**
|
||||
* Returns the target class name of the given association.
|
||||
*
|
||||
* @param string $assocName
|
||||
* @return string
|
||||
*/
|
||||
function getAssociationTargetClass($assocName);
|
||||
|
||||
/**
|
||||
* Checks if the association is the inverse side of a bidirectional association
|
||||
*
|
||||
* @param string $assocName
|
||||
* @return boolean
|
||||
*/
|
||||
function isAssociationInverseSide($assocName);
|
||||
|
||||
/**
|
||||
* Returns the target field of the owning side of the association
|
||||
*
|
||||
* @param string $assocName
|
||||
* @return string
|
||||
*/
|
||||
function getAssociationMappedByTargetField($assocName);
|
||||
|
||||
/**
|
||||
* Return the identifier of this object as an array with field name as key.
|
||||
*
|
||||
* Has to return an empty array if no identifier isset.
|
||||
*
|
||||
* @param object $object
|
||||
* @return array
|
||||
*/
|
||||
function getIdentifierValues($object);
|
||||
}
|
74
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/ClassMetadataFactory.php
vendored
Normal file
74
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/ClassMetadataFactory.php
vendored
Normal file
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping;
|
||||
|
||||
/**
|
||||
* Contract for a Doctrine persistence layer ClassMetadata class to implement.
|
||||
*
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.1
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
*/
|
||||
interface ClassMetadataFactory
|
||||
{
|
||||
/**
|
||||
* Forces the factory to load the metadata of all classes known to the underlying
|
||||
* mapping driver.
|
||||
*
|
||||
* @return array The ClassMetadata instances of all mapped classes.
|
||||
*/
|
||||
function getAllMetadata();
|
||||
|
||||
/**
|
||||
* Gets the class metadata descriptor for a class.
|
||||
*
|
||||
* @param string $className The name of the class.
|
||||
* @return ClassMetadata
|
||||
*/
|
||||
function getMetadataFor($className);
|
||||
|
||||
/**
|
||||
* Checks whether the factory has the metadata for a class loaded already.
|
||||
*
|
||||
* @param string $className
|
||||
* @return boolean TRUE if the metadata of the class in question is already loaded, FALSE otherwise.
|
||||
*/
|
||||
function hasMetadataFor($className);
|
||||
|
||||
/**
|
||||
* Sets the metadata descriptor for a specific class.
|
||||
*
|
||||
* @param string $className
|
||||
* @param ClassMetadata $class
|
||||
*/
|
||||
function setMetadataFor($className, $class);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param string $className
|
||||
* @return boolean
|
||||
*/
|
||||
function isTransient($className);
|
||||
}
|
214
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php
vendored
Normal file
214
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php
vendored
Normal file
|
@ -0,0 +1,214 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping\Driver;
|
||||
|
||||
use Doctrine\Common\Cache\ArrayCache,
|
||||
Doctrine\Common\Annotations\AnnotationReader,
|
||||
Doctrine\Common\Annotations\AnnotationRegistry,
|
||||
Doctrine\Common\Persistence\Mapping\MappingException;
|
||||
|
||||
/**
|
||||
* The AnnotationDriver reads the mapping metadata from docblock annotations.
|
||||
*
|
||||
* @since 2.2
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan H. Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
*/
|
||||
abstract class AnnotationDriver implements MappingDriver
|
||||
{
|
||||
/**
|
||||
* The AnnotationReader.
|
||||
*
|
||||
* @var AnnotationReader
|
||||
*/
|
||||
protected $reader;
|
||||
|
||||
/**
|
||||
* The paths where to look for mapping files.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $paths = array();
|
||||
|
||||
/**
|
||||
* The file extension of mapping documents.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $fileExtension = '.php';
|
||||
|
||||
/**
|
||||
* Cache for AnnotationDriver#getAllClassNames()
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $classNames;
|
||||
|
||||
/**
|
||||
* Name of the entity annotations as keys
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $entityAnnotationClasses = array();
|
||||
|
||||
/**
|
||||
* Initializes a new AnnotationDriver that uses the given AnnotationReader for reading
|
||||
* docblock annotations.
|
||||
*
|
||||
* @param AnnotationReader $reader The AnnotationReader to use, duck-typed.
|
||||
* @param string|array $paths One or multiple paths where mapping classes can be found.
|
||||
*/
|
||||
public function __construct($reader, $paths = null)
|
||||
{
|
||||
$this->reader = $reader;
|
||||
if ($paths) {
|
||||
$this->addPaths((array) $paths);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Append lookup paths to metadata driver.
|
||||
*
|
||||
* @param array $paths
|
||||
*/
|
||||
public function addPaths(array $paths)
|
||||
{
|
||||
$this->paths = array_unique(array_merge($this->paths, $paths));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the defined metadata lookup paths.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPaths()
|
||||
{
|
||||
return $this->paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the current annotation reader
|
||||
*
|
||||
* @return AnnotationReader
|
||||
*/
|
||||
public function getReader()
|
||||
{
|
||||
return $this->reader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file extension used to look for mapping files under
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFileExtension()
|
||||
{
|
||||
return $this->fileExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the file extension used to look for mapping files under
|
||||
*
|
||||
* @param string $fileExtension The file extension to set
|
||||
* @return void
|
||||
*/
|
||||
public function setFileExtension($fileExtension)
|
||||
{
|
||||
$this->fileExtension = $fileExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the class with the specified name is transient. Only non-transient
|
||||
* classes, that is entities and mapped superclasses, should have their metadata loaded.
|
||||
*
|
||||
* A class is non-transient if it is annotated with an annotation
|
||||
* from the {@see AnnotationDriver::entityAnnotationClasses}.
|
||||
*
|
||||
* @param string $className
|
||||
* @return boolean
|
||||
*/
|
||||
public function isTransient($className)
|
||||
{
|
||||
$classAnnotations = $this->reader->getClassAnnotations(new \ReflectionClass($className));
|
||||
|
||||
foreach ($classAnnotations as $annot) {
|
||||
if (isset($this->entityAnnotationClasses[get_class($annot)])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getAllClassNames()
|
||||
{
|
||||
if ($this->classNames !== null) {
|
||||
return $this->classNames;
|
||||
}
|
||||
|
||||
if (!$this->paths) {
|
||||
throw MappingException::pathRequired();
|
||||
}
|
||||
|
||||
$classes = array();
|
||||
$includedFiles = array();
|
||||
|
||||
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
|
||||
),
|
||||
'/^.+' . str_replace('.', '\.', $this->fileExtension) . '$/i',
|
||||
\RecursiveRegexIterator::GET_MATCH
|
||||
);
|
||||
|
||||
foreach ($iterator as $file) {
|
||||
$sourceFile = realpath($file[0]);
|
||||
|
||||
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) && ! $this->isTransient($className)) {
|
||||
$classes[] = $className;
|
||||
}
|
||||
}
|
||||
|
||||
$this->classNames = $classes;
|
||||
|
||||
return $classes;
|
||||
}
|
||||
}
|
170
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/DefaultFileLocator.php
vendored
Normal file
170
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/DefaultFileLocator.php
vendored
Normal file
|
@ -0,0 +1,170 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping\Driver;
|
||||
|
||||
use Doctrine\Common\Persistence\Mapping\MappingException;
|
||||
|
||||
/**
|
||||
* Locate the file that contains the metadata information for a given class name.
|
||||
*
|
||||
* This behavior is inpependent of the actual content of the file. It just detects
|
||||
* the file which is responsible for the given class name.
|
||||
*
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class DefaultFileLocator implements FileLocator
|
||||
{
|
||||
/**
|
||||
* The paths where to look for mapping files.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $paths = array();
|
||||
|
||||
/**
|
||||
* The file extension of mapping documents.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
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 $paths One or multiple paths where mapping documents can be found.
|
||||
* @param string|null $fileExtension
|
||||
*/
|
||||
public function __construct($paths, $fileExtension = null)
|
||||
{
|
||||
$this->addPaths((array) $paths);
|
||||
$this->fileExtension = $fileExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append lookup paths to metadata driver.
|
||||
*
|
||||
* @param array $paths
|
||||
*/
|
||||
public function addPaths(array $paths)
|
||||
{
|
||||
$this->paths = array_unique(array_merge($this->paths, $paths));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the defined metadata lookup paths.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPaths()
|
||||
{
|
||||
return $this->paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file extension used to look for mapping files under
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFileExtension()
|
||||
{
|
||||
return $this->fileExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the file extension used to look for mapping files under
|
||||
*
|
||||
* @param string $fileExtension The file extension to set
|
||||
* @return void
|
||||
*/
|
||||
public function setFileExtension($fileExtension)
|
||||
{
|
||||
$this->fileExtension = $fileExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function findMappingFile($className)
|
||||
{
|
||||
$fileName = str_replace('\\', '.', $className) . $this->fileExtension;
|
||||
|
||||
// Check whether file exists
|
||||
foreach ($this->paths as $path) {
|
||||
if (file_exists($path . DIRECTORY_SEPARATOR . $fileName)) {
|
||||
return $path . DIRECTORY_SEPARATOR . $fileName;
|
||||
}
|
||||
}
|
||||
|
||||
throw MappingException::mappingFileNotFound($className, $fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getAllClassNames($globalBasename)
|
||||
{
|
||||
$classes = array();
|
||||
|
||||
if ($this->paths) {
|
||||
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!
|
||||
$classes[] = str_replace('.', '\\', $fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fileExists($className)
|
||||
{
|
||||
$fileName = str_replace('\\', '.', $className) . $this->fileExtension;
|
||||
|
||||
// Check whether file exists
|
||||
foreach ((array) $this->paths as $path) {
|
||||
if (file_exists($path . DIRECTORY_SEPARATOR . $fileName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
214
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/FileDriver.php
vendored
Normal file
214
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/FileDriver.php
vendored
Normal file
|
@ -0,0 +1,214 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping\Driver;
|
||||
|
||||
use Doctrine\Common\Persistence\Mapping\MappingException;
|
||||
|
||||
/**
|
||||
* 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 '.'.
|
||||
*
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link www.doctrine-project.com
|
||||
* @since 2.2
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan H. Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
*/
|
||||
abstract class FileDriver implements MappingDriver
|
||||
{
|
||||
/**
|
||||
* @var FileLocator
|
||||
*/
|
||||
protected $locator;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
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|FileLocator $locator A FileLocator or one/multiple paths where mapping documents can be found.
|
||||
* @param string $fileExtension
|
||||
*/
|
||||
public function __construct($locator, $fileExtension = null)
|
||||
{
|
||||
if ($locator instanceof FileLocator) {
|
||||
$this->locator = $locator;
|
||||
} else {
|
||||
$this->locator = new DefaultFileLocator((array)$locator, $fileExtension);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set global basename
|
||||
*
|
||||
* @param string $file
|
||||
*/
|
||||
public function setGlobalBasename($file)
|
||||
{
|
||||
$this->globalBasename = $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve global basename
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getGlobalBasename()
|
||||
{
|
||||
return $this->globalBasename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get 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
|
||||
*
|
||||
* @param string $className
|
||||
*
|
||||
* @throws MappingException
|
||||
* @return array The element of schema meta data
|
||||
*/
|
||||
public function getElement($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());
|
||||
}
|
||||
|
||||
return $result[$className];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param string $className
|
||||
* @return boolean
|
||||
*/
|
||||
public function isTransient($className)
|
||||
{
|
||||
if ($this->classCache === null) {
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
if (isset($this->classCache[$className])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !$this->locator->fileExists($className);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the names of all mapped classes known to this driver.
|
||||
*
|
||||
* @return array The names of all mapped classes known to this driver.
|
||||
*/
|
||||
public function getAllClassNames()
|
||||
{
|
||||
if ($this->classCache === null) {
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
$classNames = (array)$this->locator->getAllClassNames($this->globalBasename);
|
||||
if ($this->classCache) {
|
||||
$classNames = array_merge(array_keys($this->classCache), $classNames);
|
||||
}
|
||||
return $classNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 array
|
||||
*/
|
||||
abstract protected function loadMappingFile($file);
|
||||
|
||||
/**
|
||||
* Initialize 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 = array();
|
||||
if (null !== $this->globalBasename) {
|
||||
foreach ($this->locator->getPaths() as $path) {
|
||||
$file = $path.'/'.$this->globalBasename.$this->locator->getFileExtension();
|
||||
if (is_file($file)) {
|
||||
$this->classCache = array_merge(
|
||||
$this->classCache,
|
||||
$this->loadMappingFile($file)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the locator used to discover mapping files by className
|
||||
*
|
||||
* @return FileLocator
|
||||
*/
|
||||
public function getLocator()
|
||||
{
|
||||
return $this->locator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the locator used to discover mapping files by className
|
||||
*
|
||||
* @param FileLocator $locator
|
||||
*/
|
||||
public function setLocator(FileLocator $locator)
|
||||
{
|
||||
$this->locator = $locator;
|
||||
}
|
||||
}
|
71
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/FileLocator.php
vendored
Normal file
71
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/FileLocator.php
vendored
Normal file
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping\Driver;
|
||||
|
||||
/**
|
||||
* Locate 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.
|
||||
*
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
interface FileLocator
|
||||
{
|
||||
/**
|
||||
* Locate mapping file for the given class name.
|
||||
*
|
||||
* @param string $className
|
||||
* @return string
|
||||
*/
|
||||
function findMappingFile($className);
|
||||
|
||||
/**
|
||||
* Get all class names that are found with this file locator.
|
||||
*
|
||||
* @param string $globalBasename Passed to allow excluding the basename
|
||||
* @return array
|
||||
*/
|
||||
function getAllClassNames($globalBasename);
|
||||
|
||||
/**
|
||||
* Check if a file can be found for this class name.
|
||||
*
|
||||
* @param string $className
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function fileExists($className);
|
||||
|
||||
/**
|
||||
* Get all the paths that this file locator looks for mapping files.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getPaths();
|
||||
|
||||
/**
|
||||
* Get the file extension that mapping files are suffixed with.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getFileExtension();
|
||||
}
|
56
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriver.php
vendored
Normal file
56
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriver.php
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping\Driver;
|
||||
|
||||
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
|
||||
|
||||
/**
|
||||
* Contract for metadata drivers.
|
||||
*
|
||||
* @since 2.2
|
||||
* @author Jonathan H. Wage <jonwage@gmail.com>
|
||||
*/
|
||||
interface MappingDriver
|
||||
{
|
||||
/**
|
||||
* Loads the metadata for the specified class into the provided container.
|
||||
*
|
||||
* @param string $className
|
||||
* @param ClassMetadata $metadata
|
||||
*/
|
||||
function loadMetadataForClass($className, ClassMetadata $metadata);
|
||||
|
||||
/**
|
||||
* Gets the names of all mapped classes known to this driver.
|
||||
*
|
||||
* @return array The names of all mapped classes known to this driver.
|
||||
*/
|
||||
function getAllClassNames();
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param string $className
|
||||
* @return boolean
|
||||
*/
|
||||
function isTransient($className);
|
||||
}
|
168
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php
vendored
Normal file
168
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php
vendored
Normal file
|
@ -0,0 +1,168 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping\Driver;
|
||||
|
||||
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver,
|
||||
Doctrine\Common\Persistence\Mapping\ClassMetadata,
|
||||
Doctrine\Common\Persistence\Mapping\MappingException;
|
||||
|
||||
/**
|
||||
* The DriverChain allows you to add multiple other mapping drivers for
|
||||
* certain namespaces
|
||||
*
|
||||
* @since 2.2
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan H. Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
*/
|
||||
class MappingDriverChain implements MappingDriver
|
||||
{
|
||||
/**
|
||||
* The default driver
|
||||
*
|
||||
* @var MappingDriver
|
||||
*/
|
||||
private $defaultDriver;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $drivers = array();
|
||||
|
||||
/**
|
||||
* Get the default driver.
|
||||
*
|
||||
* @return MappingDriver|null
|
||||
*/
|
||||
public function getDefaultDriver()
|
||||
{
|
||||
return $this->defaultDriver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default driver.
|
||||
*
|
||||
* @param MappingDriver $driver
|
||||
*/
|
||||
public function setDefaultDriver(MappingDriver $driver)
|
||||
{
|
||||
$this->defaultDriver = $driver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a nested driver.
|
||||
*
|
||||
* @param MappingDriver $nestedDriver
|
||||
* @param string $namespace
|
||||
*/
|
||||
public function addDriver(MappingDriver $nestedDriver, $namespace)
|
||||
{
|
||||
$this->drivers[$namespace] = $nestedDriver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array of nested drivers.
|
||||
*
|
||||
* @return array $drivers
|
||||
*/
|
||||
public function getDrivers()
|
||||
{
|
||||
return $this->drivers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the metadata for the specified class into the provided container.
|
||||
*
|
||||
* @param string $className
|
||||
* @param ClassMetadata $metadata
|
||||
*
|
||||
* @throws MappingException
|
||||
*/
|
||||
public function loadMetadataForClass($className, ClassMetadata $metadata)
|
||||
{
|
||||
/* @var $driver MappingDriver */
|
||||
foreach ($this->drivers as $namespace => $driver) {
|
||||
if (strpos($className, $namespace) === 0) {
|
||||
$driver->loadMetadataForClass($className, $metadata);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (null !== $this->defaultDriver) {
|
||||
$this->defaultDriver->loadMetadataForClass($className, $metadata);
|
||||
return;
|
||||
}
|
||||
|
||||
throw MappingException::classNotFoundInNamespaces($className, array_keys($this->drivers));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the names of all mapped classes known to this driver.
|
||||
*
|
||||
* @return array The names of all mapped classes known to this driver.
|
||||
*/
|
||||
public function getAllClassNames()
|
||||
{
|
||||
$classNames = array();
|
||||
$driverClasses = array();
|
||||
|
||||
/* @var $driver MappingDriver */
|
||||
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) {
|
||||
$classNames[$className] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array_keys($classNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the class with the specified name should have its metadata loaded.
|
||||
*
|
||||
* This is only the case for non-transient classes either mapped as an Entity or MappedSuperclass.
|
||||
*
|
||||
* @param string $className
|
||||
* @return boolean
|
||||
*/
|
||||
public function isTransient($className)
|
||||
{
|
||||
/* @var $driver MappingDriver */
|
||||
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;
|
||||
}
|
||||
}
|
72
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/PHPDriver.php
vendored
Normal file
72
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/PHPDriver.php
vendored
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping\Driver;
|
||||
|
||||
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
|
||||
|
||||
/**
|
||||
* The PHPDriver includes php files which just populate ClassMetadataInfo
|
||||
* instances with plain php code
|
||||
*
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.0
|
||||
* @version $Revision$
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan H. Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
*/
|
||||
class PHPDriver extends FileDriver
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $metadata;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function __construct($locator, $fileExtension = null)
|
||||
{
|
||||
$fileExtension = ".php";
|
||||
parent::__construct($locator, $fileExtension);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function loadMetadataForClass($className, ClassMetadata $metadata)
|
||||
{
|
||||
$this->metadata = $metadata;
|
||||
$this->loadMappingFile($this->locator->findMappingFile($className));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function loadMappingFile($file)
|
||||
{
|
||||
$metadata = $this->metadata;
|
||||
include $file;
|
||||
|
||||
return array($metadata->getName() => $metadata);
|
||||
}
|
||||
}
|
141
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/StaticPHPDriver.php
vendored
Normal file
141
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/StaticPHPDriver.php
vendored
Normal file
|
@ -0,0 +1,141 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping\Driver;
|
||||
|
||||
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
|
||||
use Doctrine\Common\Persistence\Mapping\MappingException;
|
||||
|
||||
/**
|
||||
* The StaticPHPDriver calls a static loadMetadata() method on your entity
|
||||
* classes where you can manually populate the ClassMetadata instance.
|
||||
*
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.2
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan H. Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
*/
|
||||
class StaticPHPDriver implements MappingDriver
|
||||
{
|
||||
/**
|
||||
* Paths of entity directories.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $paths = array();
|
||||
|
||||
/**
|
||||
* Map of all class names.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $classNames;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array|string $paths
|
||||
*/
|
||||
public function __construct($paths)
|
||||
{
|
||||
$this->addPaths((array) $paths);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add paths
|
||||
*
|
||||
* @param array $paths
|
||||
*/
|
||||
public function addPaths(array $paths)
|
||||
{
|
||||
$this->paths = array_unique(array_merge($this->paths, $paths));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function loadMetadataForClass($className, ClassMetadata $metadata)
|
||||
{
|
||||
$className::loadMetadata($metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @todo Same code exists in AnnotationDriver, 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::pathRequired();
|
||||
}
|
||||
|
||||
$classes = array();
|
||||
$includedFiles = array();
|
||||
|
||||
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) && !$this->isTransient($className)) {
|
||||
$classes[] = $className;
|
||||
}
|
||||
}
|
||||
|
||||
$this->classNames = $classes;
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isTransient($className)
|
||||
{
|
||||
return ! method_exists($className, 'loadMetadata');
|
||||
}
|
||||
}
|
214
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/SymfonyFileLocator.php
vendored
Normal file
214
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/SymfonyFileLocator.php
vendored
Normal file
|
@ -0,0 +1,214 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping\Driver;
|
||||
|
||||
use Doctrine\Common\Persistence\Mapping\MappingException;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @license MIT
|
||||
*/
|
||||
class SymfonyFileLocator implements FileLocator
|
||||
{
|
||||
/**
|
||||
* The paths where to look for mapping files.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $paths = array();
|
||||
|
||||
/**
|
||||
* A map of mapping directory path to namespace prefix used to expand class shortnames.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $prefixes = array();
|
||||
|
||||
/**
|
||||
* File extension that is searched for.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $fileExtension;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $prefixes
|
||||
* @param string|null $fileExtension
|
||||
*/
|
||||
public function __construct(array $prefixes, $fileExtension = null)
|
||||
{
|
||||
$this->addNamespacePrefixes($prefixes);
|
||||
$this->fileExtension = $fileExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Namespace Prefixes
|
||||
*
|
||||
* @param array $prefixes
|
||||
*/
|
||||
public function addNamespacePrefixes(array $prefixes)
|
||||
{
|
||||
$this->prefixes = array_merge($this->prefixes, $prefixes);
|
||||
$this->paths = array_merge($this->paths, array_keys($prefixes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Namespace Prefixes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getNamespacePrefixes()
|
||||
{
|
||||
return $this->prefixes;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getPaths()
|
||||
{
|
||||
return $this->paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getFileExtension()
|
||||
{
|
||||
return $this->fileExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the file extension used to look for mapping files under
|
||||
*
|
||||
* @param string $fileExtension The file extension to set
|
||||
* @return void
|
||||
*/
|
||||
public function setFileExtension($fileExtension)
|
||||
{
|
||||
$this->fileExtension = $fileExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fileExists($className)
|
||||
{
|
||||
$defaultFileName = str_replace('\\', '.', $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 (0 !== strpos($className, $prefix.'\\')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$filename = $path.'/'.strtr(substr($className, strlen($prefix)+1), '\\', '.').$this->fileExtension;
|
||||
return is_file($filename);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getAllClassNames($globalBasename = null)
|
||||
{
|
||||
$classes = array();
|
||||
|
||||
if ($this->paths) {
|
||||
foreach ((array) $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])) {
|
||||
$classes[] = $this->prefixes[$path].'\\'.str_replace('.', '\\', $fileName);
|
||||
} else {
|
||||
$classes[] = str_replace('.', '\\', $fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function findMappingFile($className)
|
||||
{
|
||||
$defaultFileName = str_replace('\\', '.', $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 (0 !== strpos($className, $prefix.'\\')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$filename = $path.'/'.strtr(substr($className, strlen($prefix)+1), '\\', '.').$this->fileExtension;
|
||||
if (is_file($filename)) {
|
||||
return $filename;
|
||||
}
|
||||
|
||||
throw MappingException::mappingFileNotFound($className, $filename);
|
||||
}
|
||||
|
||||
throw MappingException::mappingFileNotFound($className, substr($className, strrpos($className, '\\') + 1).$this->fileExtension);
|
||||
}
|
||||
}
|
86
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php
vendored
Normal file
86
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php
vendored
Normal file
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.phpdoctrine.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping;
|
||||
|
||||
/**
|
||||
* A MappingException indicates that something is wrong with the mapping setup.
|
||||
*
|
||||
* @since 2.2
|
||||
*/
|
||||
class MappingException extends \Exception
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @param string $className
|
||||
* @param array $namespaces
|
||||
*
|
||||
* @return MappingException
|
||||
*/
|
||||
public static function classNotFoundInNamespaces($className, $namespaces)
|
||||
{
|
||||
return new self("The class '" . $className . "' was not found in the ".
|
||||
"chain configured namespaces " . implode(", ", $namespaces));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MappingException
|
||||
*/
|
||||
public static function pathRequired()
|
||||
{
|
||||
return new self("Specifying the paths to your entities is required ".
|
||||
"in the AnnotationDriver to retrieve all class names.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $path
|
||||
* @return MappingException
|
||||
*/
|
||||
public static function fileMappingDriversRequireConfiguredDirectoryPath($path = null)
|
||||
{
|
||||
if ( ! empty($path)) {
|
||||
$path = '[' . $path . ']';
|
||||
}
|
||||
|
||||
return new self(
|
||||
'File mapping drivers must have a valid directory path, ' .
|
||||
'however the given path ' . $path . ' seems to be incorrect!'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $entityName
|
||||
* @param string $fileName
|
||||
* @return MappingException
|
||||
*/
|
||||
public static function mappingFileNotFound($entityName, $fileName)
|
||||
{
|
||||
return new self("No mapping file found named '$fileName' for class '$entityName'.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $entityName
|
||||
* @param string $fileName
|
||||
* @return MappingException
|
||||
*/
|
||||
public static function invalidMappingFile($entityName, $fileName)
|
||||
{
|
||||
return new self("Invalid mapping file '$fileName' for class '$entityName'.");
|
||||
}
|
||||
}
|
80
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/ReflectionService.php
vendored
Normal file
80
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/ReflectionService.php
vendored
Normal file
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping;
|
||||
|
||||
/**
|
||||
* Very simple reflection service abstraction.
|
||||
*
|
||||
* This is required inside metadata layers that may require either
|
||||
* static or runtime reflection.
|
||||
*
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
interface ReflectionService
|
||||
{
|
||||
/**
|
||||
* Return an array of the parent classes (not interfaces) for the given class.
|
||||
*
|
||||
* @param string $class
|
||||
* @return array
|
||||
*/
|
||||
function getParentClasses($class);
|
||||
|
||||
/**
|
||||
* Return the shortname of a class.
|
||||
*
|
||||
* @param string $class
|
||||
* @return string
|
||||
*/
|
||||
function getClassShortName($class);
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
* @return string
|
||||
*/
|
||||
function getClassNamespace($class);
|
||||
|
||||
/**
|
||||
* Return a reflection class instance or null
|
||||
*
|
||||
* @param string $class
|
||||
* @return \ReflectionClass|null
|
||||
*/
|
||||
function getClass($class);
|
||||
|
||||
/**
|
||||
* Return an accessible property (setAccessible(true)) or null.
|
||||
*
|
||||
* @param string $class
|
||||
* @param string $property
|
||||
* @return \ReflectionProperty|null
|
||||
*/
|
||||
function getAccessibleProperty($class, $property);
|
||||
|
||||
/**
|
||||
* Check if the class have a public method with the given name.
|
||||
*
|
||||
* @param mixed $class
|
||||
* @param mixed $method
|
||||
* @return bool
|
||||
*/
|
||||
function hasPublicMethod($class, $method);
|
||||
}
|
||||
|
102
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php
vendored
Normal file
102
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php
vendored
Normal file
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping;
|
||||
|
||||
use ReflectionClass;
|
||||
use ReflectionProperty;
|
||||
|
||||
/**
|
||||
* PHP Runtime Reflection Service
|
||||
*
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
class RuntimeReflectionService implements ReflectionService
|
||||
{
|
||||
/**
|
||||
* Return an array of the parent classes (not interfaces) for the given class.
|
||||
*
|
||||
* @param string $class
|
||||
* @return array
|
||||
*/
|
||||
public function getParentClasses($class)
|
||||
{
|
||||
return class_parents($class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the shortname of a class.
|
||||
*
|
||||
* @param string $class
|
||||
* @return string
|
||||
*/
|
||||
public function getClassShortName($class)
|
||||
{
|
||||
$r = new ReflectionClass($class);
|
||||
return $r->getShortName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
* @return string
|
||||
*/
|
||||
public function getClassNamespace($class)
|
||||
{
|
||||
$r = new ReflectionClass($class);
|
||||
return $r->getNamespaceName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a reflection class instance or null
|
||||
*
|
||||
* @param string $class
|
||||
* @return ReflectionClass|null
|
||||
*/
|
||||
public function getClass($class)
|
||||
{
|
||||
return new ReflectionClass($class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an accessible property (setAccessible(true)) or null.
|
||||
*
|
||||
* @param string $class
|
||||
* @param string $property
|
||||
* @return ReflectionProperty|null
|
||||
*/
|
||||
public function getAccessibleProperty($class, $property)
|
||||
{
|
||||
$property = new ReflectionProperty($class, $property);
|
||||
$property->setAccessible(true);
|
||||
return $property;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the class have a public method with the given name.
|
||||
*
|
||||
* @param mixed $class
|
||||
* @param mixed $method
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPublicMethod($class, $method)
|
||||
{
|
||||
return method_exists($class, $method) && is_callable(array($class, $method));
|
||||
}
|
||||
}
|
||||
|
107
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/StaticReflectionService.php
vendored
Normal file
107
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/StaticReflectionService.php
vendored
Normal file
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence\Mapping;
|
||||
|
||||
use ReflectionClass;
|
||||
use ReflectionProperty;
|
||||
|
||||
/**
|
||||
* PHP Runtime Reflection Service
|
||||
*
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
class StaticReflectionService implements ReflectionService
|
||||
{
|
||||
/**
|
||||
* Return an array of the parent classes (not interfaces) for the given class.
|
||||
*
|
||||
* @param string $class
|
||||
* @return array
|
||||
*/
|
||||
public function getParentClasses($class)
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the shortname of a class.
|
||||
*
|
||||
* @param string $className
|
||||
* @return string
|
||||
*/
|
||||
public function getClassShortName($className)
|
||||
{
|
||||
if (strpos($className, '\\') !== false) {
|
||||
$className = substr($className, strrpos($className, "\\")+1);
|
||||
}
|
||||
return $className;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the namespace of a class.
|
||||
*
|
||||
* @param string $className
|
||||
* @return string
|
||||
*/
|
||||
public function getClassNamespace($className)
|
||||
{
|
||||
$namespace = '';
|
||||
if (strpos($className, '\\') !== false) {
|
||||
$namespace = strrev(substr( strrev($className), strpos(strrev($className), '\\')+1 ));
|
||||
}
|
||||
return $namespace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a reflection class instance or null
|
||||
*
|
||||
* @param string $class
|
||||
* @return ReflectionClass|null
|
||||
*/
|
||||
public function getClass($class)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an accessible property (setAccessible(true)) or null.
|
||||
*
|
||||
* @param string $class
|
||||
* @param string $property
|
||||
* @return ReflectionProperty|null
|
||||
*/
|
||||
public function getAccessibleProperty($class, $property)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the class have a public method with the given name.
|
||||
*
|
||||
* @param mixed $class
|
||||
* @param mixed $method
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPublicMethod($class, $method)
|
||||
{
|
||||
return method_exists($class, $method) && is_callable(array($class, $method));
|
||||
}
|
||||
}
|
||||
|
152
vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectManager.php
vendored
Normal file
152
vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectManager.php
vendored
Normal file
|
@ -0,0 +1,152 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence;
|
||||
|
||||
/**
|
||||
* Contract for a Doctrine persistence layer ObjectManager class to implement.
|
||||
*
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.1
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
*/
|
||||
interface ObjectManager
|
||||
{
|
||||
/**
|
||||
* Finds a object by its identifier.
|
||||
*
|
||||
* This is just a convenient shortcut for getRepository($className)->find($id).
|
||||
*
|
||||
* @param string
|
||||
* @param mixed
|
||||
* @return object
|
||||
*/
|
||||
function find($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.
|
||||
*/
|
||||
function persist($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.
|
||||
*/
|
||||
function remove($object);
|
||||
|
||||
/**
|
||||
* Merges the state of a detached object into the persistence context
|
||||
* of this ObjectManager and returns the managed copy of the object.
|
||||
* The object passed to merge will not become associated/managed with this ObjectManager.
|
||||
*
|
||||
* @param object $object
|
||||
* @return object
|
||||
*/
|
||||
function merge($object);
|
||||
|
||||
/**
|
||||
* Clears the ObjectManager. All objects that are currently managed
|
||||
* by this ObjectManager become detached.
|
||||
*
|
||||
* @param string $objectName if given, only objects of this type will get detached
|
||||
*/
|
||||
function clear($objectName = null);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
function detach($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.
|
||||
*/
|
||||
function refresh($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.
|
||||
*/
|
||||
function flush();
|
||||
|
||||
/**
|
||||
* Gets the repository for a class.
|
||||
*
|
||||
* @param string $className
|
||||
* @return \Doctrine\Common\Persistence\ObjectRepository
|
||||
*/
|
||||
function getRepository($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)).
|
||||
*
|
||||
* @param string $className
|
||||
* @return \Doctrine\Common\Persistence\Mapping\ClassMetadata
|
||||
*/
|
||||
function getClassMetadata($className);
|
||||
|
||||
/**
|
||||
* Gets the metadata factory used to gather the metadata of classes.
|
||||
*
|
||||
* @return \Doctrine\Common\Persistence\Mapping\ClassMetadataFactory
|
||||
*/
|
||||
function getMetadataFactory();
|
||||
|
||||
/**
|
||||
* Helper method to initialize a lazy loading proxy or persistent collection.
|
||||
*
|
||||
* This method is a no-op for other objects.
|
||||
*
|
||||
* @param object $obj
|
||||
*/
|
||||
function initializeObject($obj);
|
||||
|
||||
/**
|
||||
* Check if the object is part of the current UnitOfWork and therefore
|
||||
* managed.
|
||||
*
|
||||
* @param object $object
|
||||
* @return bool
|
||||
*/
|
||||
function contains($object);
|
||||
}
|
49
vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectManagerAware.php
vendored
Normal file
49
vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectManagerAware.php
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence;
|
||||
|
||||
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
|
||||
|
||||
/**
|
||||
* Makes a Persistent Objects aware of its own object-manager.
|
||||
*
|
||||
* Using this interface the managing object manager and class metadata instances
|
||||
* are injected into the persistent object after construction. This allows
|
||||
* you to implement ActiveRecord functionality on top of the persistance-ignorance
|
||||
* that Doctrine propagates.
|
||||
*
|
||||
* Word of Warning: This is a very powerful hook to change how you can work with your domain models.
|
||||
* Using this hook will break the Single Responsibility Principle inside your Domain Objects
|
||||
* and increase the coupling of database and objects.
|
||||
*
|
||||
* Every ObjectManager has to implement this functionality itself.
|
||||
*
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
interface ObjectManagerAware
|
||||
{
|
||||
/**
|
||||
* Injects responsible ObjectManager and the ClassMetadata into this persistent object.
|
||||
*
|
||||
* @param ObjectManager $objectManager
|
||||
* @param ClassMetadata $classMetadata
|
||||
*/
|
||||
public function injectObjectManager(ObjectManager $objectManager, ClassMetadata $classMetadata);
|
||||
}
|
78
vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectRepository.php
vendored
Normal file
78
vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectRepository.php
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence;
|
||||
|
||||
/**
|
||||
* Contract for a Doctrine persistence layer ObjectRepository class to implement.
|
||||
*
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.1
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
*/
|
||||
interface ObjectRepository
|
||||
{
|
||||
/**
|
||||
* Finds an object by its primary key / identifier.
|
||||
*
|
||||
* @param int $id The identifier.
|
||||
* @return object The object.
|
||||
*/
|
||||
function find($id);
|
||||
|
||||
/**
|
||||
* Finds all objects in the repository.
|
||||
*
|
||||
* @return mixed The objects.
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @throws \UnexpectedValueException
|
||||
* @param array $criteria
|
||||
* @param array|null $orderBy
|
||||
* @param int|null $limit
|
||||
* @param int|null $offset
|
||||
* @return mixed The objects.
|
||||
*/
|
||||
function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null);
|
||||
|
||||
/**
|
||||
* Finds a single object by a set of criteria.
|
||||
*
|
||||
* @param array $criteria
|
||||
* @return object The object.
|
||||
*/
|
||||
function findOneBy(array $criteria);
|
||||
|
||||
/**
|
||||
* Returns the class name of the object managed by the repository
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getClassName();
|
||||
}
|
244
vendor/doctrine/common/lib/Doctrine/Common/Persistence/PersistentObject.php
vendored
Normal file
244
vendor/doctrine/common/lib/Doctrine/Common/Persistence/PersistentObject.php
vendored
Normal file
|
@ -0,0 +1,244 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence;
|
||||
|
||||
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
/**
|
||||
* 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 aswell. Setting objects on the owning side
|
||||
* will not set the inverse side associations.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* PersistentObject::setObjectManager($em);
|
||||
*
|
||||
* class Foo extends PersistentObject
|
||||
* {
|
||||
* private $id;
|
||||
* }
|
||||
*
|
||||
* $foo = new Foo();
|
||||
* $foo->getId(); // method exists through __call
|
||||
*
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
abstract class PersistentObject implements ObjectManagerAware
|
||||
{
|
||||
/**
|
||||
* @var ObjectManager
|
||||
*/
|
||||
private static $objectManager;
|
||||
|
||||
/**
|
||||
* @var ClassMetadata
|
||||
*/
|
||||
private $cm;
|
||||
|
||||
/**
|
||||
* Set the object manager responsible for all persistent object base classes.
|
||||
*
|
||||
* @param ObjectManager $objectManager
|
||||
*/
|
||||
static public function setObjectManager(ObjectManager $objectManager = null)
|
||||
{
|
||||
self::$objectManager = $objectManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ObjectManager
|
||||
*/
|
||||
static public function getObjectManager()
|
||||
{
|
||||
return self::$objectManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject Doctrine Object Manager
|
||||
*
|
||||
* @param ObjectManager $objectManager
|
||||
* @param ClassMetadata $classMetadata
|
||||
*
|
||||
* @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 array $args
|
||||
*
|
||||
* @throws \BadMethodCallException - When no persistent field exists by that name.
|
||||
* @throws \InvalidArgumentException - When the wrong target object type is passed to an association
|
||||
* @return void
|
||||
*/
|
||||
private function set($field, $args)
|
||||
{
|
||||
$this->initializeDoctrine();
|
||||
|
||||
if ($this->cm->hasField($field) && !$this->cm->isIdentifier($field)) {
|
||||
$this->$field = $args[0];
|
||||
} else if ($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()."'");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get persistent field value.
|
||||
*
|
||||
*
|
||||
* @param string $field
|
||||
*
|
||||
* @throws \BadMethodCallException - When no persistent field exists by that name.
|
||||
* @return mixed
|
||||
*/
|
||||
private function get($field)
|
||||
{
|
||||
$this->initializeDoctrine();
|
||||
|
||||
if ( $this->cm->hasField($field) || $this->cm->hasAssociation($field) ) {
|
||||
return $this->$field;
|
||||
} else {
|
||||
throw new \BadMethodCallException("no field with name '".$field."' exists on '".$this->cm->getName()."'");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If this is an inverse side association complete the owning side.
|
||||
*
|
||||
* @param string $field
|
||||
* @param ClassMetadata $targetClass
|
||||
* @param object $targetObject
|
||||
*/
|
||||
private function completeOwningSide($field, $targetClass, $targetObject)
|
||||
{
|
||||
// add this object on the owning side aswell, for obvious infinite recursion
|
||||
// reasons this is only done when called on the inverse side.
|
||||
if ($this->cm->isAssociationInverseSide($field)) {
|
||||
$mappedByField = $this->cm->getAssociationMappedByTargetField($field);
|
||||
$targetMetadata = self::$objectManager->getClassMetadata($targetClass);
|
||||
|
||||
$setter = ($targetMetadata->isCollectionValuedAssociation($mappedByField) ? "add" : "set").$mappedByField;
|
||||
$targetObject->$setter($this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an object to a collection
|
||||
*
|
||||
* @param string $field
|
||||
* @param array $args
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
private function add($field, $args)
|
||||
{
|
||||
$this->initializeDoctrine();
|
||||
|
||||
if ($this->cm->hasAssociation($field) && $this->cm->isCollectionValuedAssociation($field)) {
|
||||
$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 ?: array());
|
||||
}
|
||||
$this->$field->add($args[0]);
|
||||
$this->completeOwningSide($field, $targetClass, $args[0]);
|
||||
} else {
|
||||
throw new \BadMethodCallException("There is no method add".$field."() on ".$this->cm->getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Doctrine Metadata for this class.
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
* @return void
|
||||
*/
|
||||
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(get_class($this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic method that implements
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $args
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $args)
|
||||
{
|
||||
$command = substr($method, 0, 3);
|
||||
$field = lcfirst(substr($method, 3));
|
||||
if ($command == "set") {
|
||||
$this->set($field, $args);
|
||||
} else if ($command == "get") {
|
||||
return $this->get($field);
|
||||
} else if ($command == "add") {
|
||||
$this->add($field, $args);
|
||||
} else {
|
||||
throw new \BadMethodCallException("There is no method ".$method." on ".$this->cm->getName());
|
||||
}
|
||||
}
|
||||
}
|
60
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Proxy.php
vendored
Normal file
60
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Proxy.php
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Persistence;
|
||||
|
||||
/**
|
||||
* Interface for proxy classes.
|
||||
*
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @since 2.2
|
||||
*/
|
||||
interface Proxy
|
||||
{
|
||||
/**
|
||||
* Marker for Proxy class names.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const MARKER = '__CG__';
|
||||
|
||||
/**
|
||||
* Length of the proxy marker
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const MARKER_LENGTH = 6;
|
||||
|
||||
/**
|
||||
* Initialize this proxy if its not yet initialized.
|
||||
*
|
||||
* Acts as a no-op if already initialized.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __load();
|
||||
|
||||
/**
|
||||
* Is this proxy initialized or not.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function __isInitialized();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue