2010-03-05 19:35:00 +03:00
|
|
|
<?php
|
2008-06-15 19:56:28 +04:00
|
|
|
/*
|
|
|
|
* 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
|
2012-05-26 16:37:00 +04:00
|
|
|
* and is licensed under the MIT license. For more information, see
|
2009-05-03 22:07:57 +04:00
|
|
|
* <http://www.doctrine-project.org>.
|
2008-06-15 19:56:28 +04:00
|
|
|
*/
|
2008-06-05 23:01:58 +04:00
|
|
|
|
2009-01-22 22:38:10 +03:00
|
|
|
namespace Doctrine\ORM;
|
2008-06-05 23:01:58 +04:00
|
|
|
|
2012-10-12 15:53:20 +04:00
|
|
|
use Doctrine\Common\Annotations\AnnotationReader;
|
2013-06-14 05:47:40 +04:00
|
|
|
use Doctrine\Common\Annotations\AnnotationRegistry;
|
|
|
|
use Doctrine\Common\Annotations\CachedReader;
|
|
|
|
use Doctrine\Common\Annotations\SimpleAnnotationReader;
|
|
|
|
use Doctrine\Common\Cache\ArrayCache;
|
2013-10-03 21:55:55 +04:00
|
|
|
use Doctrine\Common\Cache\Cache as CacheDriver;
|
2014-11-08 17:54:35 +03:00
|
|
|
use Doctrine\Common\Proxy\AbstractProxyFactory;
|
2013-10-03 21:55:55 +04:00
|
|
|
use Doctrine\ORM\Cache\CacheConfiguration;
|
2012-10-12 15:53:20 +04:00
|
|
|
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver;
|
2013-06-14 05:47:40 +04:00
|
|
|
use Doctrine\ORM\Mapping\DefaultEntityListenerResolver;
|
2012-10-12 15:53:20 +04:00
|
|
|
use Doctrine\ORM\Mapping\DefaultNamingStrategy;
|
2013-06-14 05:47:40 +04:00
|
|
|
use Doctrine\ORM\Mapping\DefaultQuoteStrategy;
|
|
|
|
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
|
2012-08-13 05:10:47 +04:00
|
|
|
use Doctrine\ORM\Mapping\EntityListenerResolver;
|
2013-06-14 05:47:40 +04:00
|
|
|
use Doctrine\ORM\Mapping\NamingStrategy;
|
|
|
|
use Doctrine\ORM\Mapping\QuoteStrategy;
|
|
|
|
use Doctrine\ORM\Repository\DefaultRepositoryFactory;
|
2013-06-14 07:31:18 +04:00
|
|
|
use Doctrine\ORM\Repository\RepositoryFactory;
|
2010-04-10 19:35:18 +04:00
|
|
|
|
2008-06-05 23:01:58 +04:00
|
|
|
/**
|
2009-01-03 22:50:13 +03:00
|
|
|
* Configuration container for all configuration options of Doctrine.
|
2008-06-15 19:56:28 +04:00
|
|
|
* It combines all configuration options from DBAL & ORM.
|
2008-06-05 23:01:58 +04:00
|
|
|
*
|
2015-03-15 18:53:34 +03:00
|
|
|
* Internal note: When adding a new configuration option just write a getter/setter pair.
|
|
|
|
*
|
2008-06-05 23:01:58 +04:00
|
|
|
* @since 2.0
|
2010-03-31 01:14:17 +04:00
|
|
|
* @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>
|
2008-06-05 23:01:58 +04:00
|
|
|
*/
|
2009-01-22 22:38:10 +03:00
|
|
|
class Configuration extends \Doctrine\DBAL\Configuration
|
2010-03-05 19:35:00 +03:00
|
|
|
{
|
2009-05-13 19:19:27 +04:00
|
|
|
/**
|
2009-10-15 00:18:36 +04:00
|
|
|
* Sets the directory where Doctrine generates any necessary proxy class files.
|
2009-05-13 19:19:27 +04:00
|
|
|
*
|
|
|
|
* @param string $dir
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
|
|
|
* @return void
|
2009-05-13 19:19:27 +04:00
|
|
|
*/
|
2009-10-15 00:18:36 +04:00
|
|
|
public function setProxyDir($dir)
|
2009-05-11 14:43:27 +04:00
|
|
|
{
|
2009-10-15 00:18:36 +04:00
|
|
|
$this->_attributes['proxyDir'] = $dir;
|
2009-05-11 14:43:27 +04:00
|
|
|
}
|
|
|
|
|
2009-05-13 19:19:27 +04:00
|
|
|
/**
|
2009-10-15 00:18:36 +04:00
|
|
|
* Gets the directory where Doctrine generates any necessary proxy class files.
|
2009-05-13 19:19:27 +04:00
|
|
|
*
|
2012-12-01 20:28:06 +04:00
|
|
|
* @return string|null
|
2009-05-13 19:19:27 +04:00
|
|
|
*/
|
2009-10-15 00:18:36 +04:00
|
|
|
public function getProxyDir()
|
2009-05-11 14:43:27 +04:00
|
|
|
{
|
2012-03-15 09:08:28 +04:00
|
|
|
return isset($this->_attributes['proxyDir'])
|
|
|
|
? $this->_attributes['proxyDir']
|
|
|
|
: null;
|
2009-10-15 00:18:36 +04:00
|
|
|
}
|
2010-03-05 19:35:00 +03:00
|
|
|
|
2009-10-15 00:18:36 +04:00
|
|
|
/**
|
2014-11-08 17:54:35 +03:00
|
|
|
* Gets the strategy for automatically generating proxy classes.
|
2009-10-15 00:18:36 +04:00
|
|
|
*
|
2014-11-08 17:54:35 +03:00
|
|
|
* @return int Possible values are constants of Doctrine\Common\Proxy\AbstractProxyFactory.
|
2009-10-15 00:18:36 +04:00
|
|
|
*/
|
|
|
|
public function getAutoGenerateProxyClasses()
|
|
|
|
{
|
2012-03-15 09:08:28 +04:00
|
|
|
return isset($this->_attributes['autoGenerateProxyClasses'])
|
|
|
|
? $this->_attributes['autoGenerateProxyClasses']
|
2014-11-08 17:54:35 +03:00
|
|
|
: AbstractProxyFactory::AUTOGENERATE_ALWAYS;
|
2009-10-15 00:18:36 +04:00
|
|
|
}
|
2010-03-05 19:35:00 +03:00
|
|
|
|
2009-10-15 00:18:36 +04:00
|
|
|
/**
|
2014-11-08 17:54:35 +03:00
|
|
|
* Sets the strategy for automatically generating proxy classes.
|
2009-10-15 00:18:36 +04:00
|
|
|
*
|
2014-11-08 17:54:35 +03:00
|
|
|
* @param boolean|int $autoGenerate Possible values are constants of Doctrine\Common\Proxy\AbstractProxyFactory.
|
|
|
|
* True is converted to AUTOGENERATE_ALWAYS, false to AUTOGENERATE_NEVER.
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
|
|
|
* @return void
|
2009-10-15 00:18:36 +04:00
|
|
|
*/
|
2014-11-08 17:54:35 +03:00
|
|
|
public function setAutoGenerateProxyClasses($autoGenerate)
|
2009-10-15 00:18:36 +04:00
|
|
|
{
|
2014-11-08 17:54:35 +03:00
|
|
|
$this->_attributes['autoGenerateProxyClasses'] = (int)$autoGenerate;
|
2009-10-15 00:18:36 +04:00
|
|
|
}
|
2010-03-05 19:35:00 +03:00
|
|
|
|
2010-03-15 20:19:00 +03:00
|
|
|
/**
|
|
|
|
* Gets the namespace where proxy classes reside.
|
2011-08-05 18:48:05 +04:00
|
|
|
*
|
2012-12-01 20:28:06 +04:00
|
|
|
* @return string|null
|
2010-03-15 20:19:00 +03:00
|
|
|
*/
|
2009-10-15 00:18:36 +04:00
|
|
|
public function getProxyNamespace()
|
|
|
|
{
|
2012-03-15 09:08:28 +04:00
|
|
|
return isset($this->_attributes['proxyNamespace'])
|
|
|
|
? $this->_attributes['proxyNamespace']
|
|
|
|
: null;
|
2009-10-15 00:18:36 +04:00
|
|
|
}
|
2010-03-05 19:35:00 +03:00
|
|
|
|
2010-03-15 20:19:00 +03:00
|
|
|
/**
|
|
|
|
* Sets the namespace where proxy classes reside.
|
2011-08-05 18:48:05 +04:00
|
|
|
*
|
2010-03-15 20:19:00 +03:00
|
|
|
* @param string $ns
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
|
|
|
* @return void
|
2010-03-15 20:19:00 +03:00
|
|
|
*/
|
2009-10-15 00:18:36 +04:00
|
|
|
public function setProxyNamespace($ns)
|
|
|
|
{
|
|
|
|
$this->_attributes['proxyNamespace'] = $ns;
|
2009-05-11 14:43:27 +04:00
|
|
|
}
|
|
|
|
|
2009-05-13 19:19:27 +04:00
|
|
|
/**
|
|
|
|
* Sets the cache driver implementation that is used for metadata caching.
|
|
|
|
*
|
2012-01-17 20:58:56 +04:00
|
|
|
* @param MappingDriver $driverImpl
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*
|
2009-12-16 00:06:32 +03:00
|
|
|
* @todo Force parameter to be a Closure to ensure lazy evaluation
|
|
|
|
* (as soon as a metadata cache is in effect, the driver never needs to initialize).
|
2009-05-13 19:19:27 +04:00
|
|
|
*/
|
2012-01-17 20:58:56 +04:00
|
|
|
public function setMetadataDriverImpl(MappingDriver $driverImpl)
|
2009-01-06 20:22:23 +03:00
|
|
|
{
|
|
|
|
$this->_attributes['metadataDriverImpl'] = $driverImpl;
|
|
|
|
}
|
|
|
|
|
2010-04-11 13:06:54 +04:00
|
|
|
/**
|
2012-12-13 21:56:25 +04:00
|
|
|
* Adds a new default annotation driver with a correctly configured annotation reader. If $useSimpleAnnotationReader
|
2012-07-08 17:16:35 +04:00
|
|
|
* is true, the notation `@Entity` will work, otherwise, the notation `@ORM\Entity` will be supported.
|
2011-08-05 18:48:05 +04:00
|
|
|
*
|
2010-04-11 13:06:54 +04:00
|
|
|
* @param array $paths
|
2012-12-01 20:28:06 +04:00
|
|
|
* @param bool $useSimpleAnnotationReader
|
|
|
|
*
|
2012-07-08 16:58:06 +04:00
|
|
|
* @return AnnotationDriver
|
2010-04-11 13:06:54 +04:00
|
|
|
*/
|
2012-07-08 19:33:50 +04:00
|
|
|
public function newDefaultAnnotationDriver($paths = array(), $useSimpleAnnotationReader = true)
|
2010-04-11 13:06:54 +04:00
|
|
|
{
|
2012-07-08 16:58:06 +04:00
|
|
|
AnnotationRegistry::registerFile(__DIR__ . '/Mapping/Driver/DoctrineAnnotations.php');
|
2012-03-15 09:08:28 +04:00
|
|
|
|
2012-07-08 17:16:35 +04:00
|
|
|
if ($useSimpleAnnotationReader) {
|
2012-07-08 16:58:06 +04:00
|
|
|
// Register the ORM Annotations in the AnnotationRegistry
|
|
|
|
$reader = new SimpleAnnotationReader();
|
|
|
|
$reader->addNamespace('Doctrine\ORM\Mapping');
|
|
|
|
$cachedReader = new CachedReader($reader, new ArrayCache());
|
2012-07-08 17:16:35 +04:00
|
|
|
|
2012-07-08 16:58:06 +04:00
|
|
|
return new AnnotationDriver($cachedReader, (array) $paths);
|
2011-05-25 02:26:20 +04:00
|
|
|
}
|
2012-03-15 09:08:28 +04:00
|
|
|
|
2012-07-08 16:58:06 +04:00
|
|
|
return new AnnotationDriver(
|
|
|
|
new CachedReader(new AnnotationReader(), new ArrayCache()),
|
|
|
|
(array) $paths
|
|
|
|
);
|
2010-04-11 13:06:54 +04:00
|
|
|
}
|
|
|
|
|
2010-02-26 21:11:53 +03:00
|
|
|
/**
|
2010-03-15 20:19:00 +03:00
|
|
|
* Adds a namespace under a certain alias.
|
2010-02-26 21:11:53 +03:00
|
|
|
*
|
|
|
|
* @param string $alias
|
2010-03-03 04:30:00 +03:00
|
|
|
* @param string $namespace
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
|
|
|
* @return void
|
2010-02-26 21:11:53 +03:00
|
|
|
*/
|
2010-03-03 04:30:00 +03:00
|
|
|
public function addEntityNamespace($alias, $namespace)
|
2010-02-26 21:11:53 +03:00
|
|
|
{
|
2010-03-03 04:30:00 +03:00
|
|
|
$this->_attributes['entityNamespaces'][$alias] = $namespace;
|
2010-02-26 21:11:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-03-15 20:19:00 +03:00
|
|
|
* Resolves a registered namespace alias to the full namespace.
|
2010-02-26 21:11:53 +03:00
|
|
|
*
|
2011-08-05 18:48:05 +04:00
|
|
|
* @param string $entityNamespaceAlias
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
2010-03-03 04:30:00 +03:00
|
|
|
* @return string
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
|
|
|
* @throws ORMException
|
2010-02-26 21:11:53 +03:00
|
|
|
*/
|
2010-03-03 04:30:00 +03:00
|
|
|
public function getEntityNamespace($entityNamespaceAlias)
|
2010-02-26 21:11:53 +03:00
|
|
|
{
|
2010-03-15 20:19:00 +03:00
|
|
|
if ( ! isset($this->_attributes['entityNamespaces'][$entityNamespaceAlias])) {
|
|
|
|
throw ORMException::unknownEntityNamespace($entityNamespaceAlias);
|
2010-03-03 04:30:00 +03:00
|
|
|
}
|
|
|
|
|
2010-03-15 20:19:00 +03:00
|
|
|
return trim($this->_attributes['entityNamespaces'][$entityNamespaceAlias], '\\');
|
2010-02-26 21:11:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-12-01 20:28:06 +04:00
|
|
|
* Sets the entity alias map.
|
2010-02-26 21:11:53 +03:00
|
|
|
*
|
2012-07-08 16:58:06 +04:00
|
|
|
* @param array $entityNamespaces
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
|
|
|
* @return void
|
2010-02-26 21:11:53 +03:00
|
|
|
*/
|
2010-03-03 04:30:00 +03:00
|
|
|
public function setEntityNamespaces(array $entityNamespaces)
|
2010-02-26 21:11:53 +03:00
|
|
|
{
|
2010-03-15 20:19:00 +03:00
|
|
|
$this->_attributes['entityNamespaces'] = $entityNamespaces;
|
2010-02-26 21:11:53 +03:00
|
|
|
}
|
2011-08-05 18:48:05 +04:00
|
|
|
|
2011-05-06 08:41:34 +04:00
|
|
|
/**
|
|
|
|
* Retrieves the list of registered entity namespace aliases.
|
2011-08-05 18:48:05 +04:00
|
|
|
*
|
2011-05-06 08:41:34 +04:00
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getEntityNamespaces()
|
|
|
|
{
|
|
|
|
return $this->_attributes['entityNamespaces'];
|
|
|
|
}
|
2010-02-26 21:11:53 +03:00
|
|
|
|
2009-05-13 19:19:27 +04:00
|
|
|
/**
|
|
|
|
* Gets the cache driver implementation that is used for the mapping metadata.
|
|
|
|
*
|
2012-12-01 20:28:06 +04:00
|
|
|
* @return MappingDriver|null
|
|
|
|
*
|
2010-04-10 19:35:18 +04:00
|
|
|
* @throws ORMException
|
2009-05-13 19:19:27 +04:00
|
|
|
*/
|
2009-01-06 20:22:23 +03:00
|
|
|
public function getMetadataDriverImpl()
|
|
|
|
{
|
2012-03-15 09:08:28 +04:00
|
|
|
return isset($this->_attributes['metadataDriverImpl'])
|
|
|
|
? $this->_attributes['metadataDriverImpl']
|
|
|
|
: null;
|
2009-01-06 20:22:23 +03:00
|
|
|
}
|
2009-05-13 19:19:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the cache driver implementation that is used for the query cache (SQL cache).
|
|
|
|
*
|
2012-12-01 20:28:06 +04:00
|
|
|
* @return \Doctrine\Common\Cache\Cache|null
|
2009-05-13 19:19:27 +04:00
|
|
|
*/
|
2008-08-31 22:27:16 +04:00
|
|
|
public function getQueryCacheImpl()
|
|
|
|
{
|
2012-03-15 09:08:28 +04:00
|
|
|
return isset($this->_attributes['queryCacheImpl'])
|
|
|
|
? $this->_attributes['queryCacheImpl']
|
|
|
|
: null;
|
2008-08-31 22:27:16 +04:00
|
|
|
}
|
2009-05-13 19:19:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the cache driver implementation that is used for the query cache (SQL cache).
|
|
|
|
*
|
2010-04-10 19:35:18 +04:00
|
|
|
* @param \Doctrine\Common\Cache\Cache $cacheImpl
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
|
|
|
* @return void
|
2009-05-13 19:19:27 +04:00
|
|
|
*/
|
2013-10-03 21:55:55 +04:00
|
|
|
public function setQueryCacheImpl(CacheDriver $cacheImpl)
|
2008-08-31 22:27:16 +04:00
|
|
|
{
|
|
|
|
$this->_attributes['queryCacheImpl'] = $cacheImpl;
|
|
|
|
}
|
2009-05-13 19:19:27 +04:00
|
|
|
|
2012-04-06 00:40:40 +04:00
|
|
|
/**
|
|
|
|
* Gets the cache driver implementation that is used for the hydration cache (SQL cache).
|
|
|
|
*
|
2012-12-01 20:28:06 +04:00
|
|
|
* @return \Doctrine\Common\Cache\Cache|null
|
2012-04-06 00:40:40 +04:00
|
|
|
*/
|
|
|
|
public function getHydrationCacheImpl()
|
|
|
|
{
|
|
|
|
return isset($this->_attributes['hydrationCacheImpl'])
|
|
|
|
? $this->_attributes['hydrationCacheImpl']
|
|
|
|
: null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the cache driver implementation that is used for the hydration cache (SQL cache).
|
|
|
|
*
|
|
|
|
* @param \Doctrine\Common\Cache\Cache $cacheImpl
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
|
|
|
* @return void
|
2012-04-06 00:40:40 +04:00
|
|
|
*/
|
2013-10-03 21:55:55 +04:00
|
|
|
public function setHydrationCacheImpl(CacheDriver $cacheImpl)
|
2012-04-06 00:40:40 +04:00
|
|
|
{
|
|
|
|
$this->_attributes['hydrationCacheImpl'] = $cacheImpl;
|
|
|
|
}
|
|
|
|
|
2009-05-13 19:19:27 +04:00
|
|
|
/**
|
|
|
|
* Gets the cache driver implementation that is used for metadata caching.
|
|
|
|
*
|
2012-12-01 20:28:06 +04:00
|
|
|
* @return \Doctrine\Common\Cache\Cache|null
|
2009-05-13 19:19:27 +04:00
|
|
|
*/
|
2008-08-31 22:27:16 +04:00
|
|
|
public function getMetadataCacheImpl()
|
|
|
|
{
|
2012-03-15 09:08:28 +04:00
|
|
|
return isset($this->_attributes['metadataCacheImpl'])
|
|
|
|
? $this->_attributes['metadataCacheImpl']
|
|
|
|
: null;
|
2008-08-31 22:27:16 +04:00
|
|
|
}
|
2009-05-13 19:19:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the cache driver implementation that is used for metadata caching.
|
|
|
|
*
|
2010-04-10 19:35:18 +04:00
|
|
|
* @param \Doctrine\Common\Cache\Cache $cacheImpl
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
|
|
|
* @return void
|
2009-05-13 19:19:27 +04:00
|
|
|
*/
|
2013-10-03 21:55:55 +04:00
|
|
|
public function setMetadataCacheImpl(CacheDriver $cacheImpl)
|
2008-08-31 22:27:16 +04:00
|
|
|
{
|
|
|
|
$this->_attributes['metadataCacheImpl'] = $cacheImpl;
|
|
|
|
}
|
2010-03-05 19:35:00 +03:00
|
|
|
|
2009-08-11 14:51:38 +04:00
|
|
|
/**
|
|
|
|
* Adds a named DQL query to the configuration.
|
2010-03-05 19:35:00 +03:00
|
|
|
*
|
2009-08-11 14:51:38 +04:00
|
|
|
* @param string $name The name of the query.
|
2012-12-01 20:28:06 +04:00
|
|
|
* @param string $dql The DQL query string.
|
|
|
|
*
|
|
|
|
* @return void
|
2009-08-11 14:51:38 +04:00
|
|
|
*/
|
|
|
|
public function addNamedQuery($name, $dql)
|
|
|
|
{
|
|
|
|
$this->_attributes['namedQueries'][$name] = $dql;
|
|
|
|
}
|
2010-03-05 19:35:00 +03:00
|
|
|
|
2009-08-11 14:51:38 +04:00
|
|
|
/**
|
|
|
|
* Gets a previously registered named DQL query.
|
2010-03-05 19:35:00 +03:00
|
|
|
*
|
2009-08-11 14:51:38 +04:00
|
|
|
* @param string $name The name of the query.
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
2009-08-11 14:51:38 +04:00
|
|
|
* @return string The DQL query.
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
|
|
|
* @throws ORMException
|
2009-08-11 14:51:38 +04:00
|
|
|
*/
|
|
|
|
public function getNamedQuery($name)
|
|
|
|
{
|
2010-03-15 20:19:00 +03:00
|
|
|
if ( ! isset($this->_attributes['namedQueries'][$name])) {
|
|
|
|
throw ORMException::namedQueryNotFound($name);
|
|
|
|
}
|
2012-03-15 09:08:28 +04:00
|
|
|
|
2009-08-11 14:51:38 +04:00
|
|
|
return $this->_attributes['namedQueries'][$name];
|
|
|
|
}
|
2010-03-05 19:35:00 +03:00
|
|
|
|
2009-08-11 14:51:38 +04:00
|
|
|
/**
|
|
|
|
* Adds a named native query to the configuration.
|
2010-03-05 19:35:00 +03:00
|
|
|
*
|
2012-07-08 16:58:06 +04:00
|
|
|
* @param string $name The name of the query.
|
|
|
|
* @param string $sql The native SQL query string.
|
|
|
|
* @param Query\ResultSetMapping $rsm The ResultSetMapping used for the results of the SQL query.
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
|
|
|
* @return void
|
2009-08-11 14:51:38 +04:00
|
|
|
*/
|
|
|
|
public function addNamedNativeQuery($name, $sql, Query\ResultSetMapping $rsm)
|
|
|
|
{
|
|
|
|
$this->_attributes['namedNativeQueries'][$name] = array($sql, $rsm);
|
|
|
|
}
|
2010-03-05 19:35:00 +03:00
|
|
|
|
2009-08-11 14:51:38 +04:00
|
|
|
/**
|
|
|
|
* Gets the components of a previously registered named native query.
|
2010-03-05 19:35:00 +03:00
|
|
|
*
|
2012-12-01 20:28:06 +04:00
|
|
|
* @param string $name The name of the query.
|
|
|
|
*
|
|
|
|
* @return array A tuple with the first element being the SQL string and the second
|
|
|
|
* element being the ResultSetMapping.
|
|
|
|
*
|
2012-07-08 16:58:06 +04:00
|
|
|
* @throws ORMException
|
2009-08-11 14:51:38 +04:00
|
|
|
*/
|
|
|
|
public function getNamedNativeQuery($name)
|
|
|
|
{
|
2010-03-15 20:19:00 +03:00
|
|
|
if ( ! isset($this->_attributes['namedNativeQueries'][$name])) {
|
|
|
|
throw ORMException::namedNativeQueryNotFound($name);
|
|
|
|
}
|
2012-03-15 09:08:28 +04:00
|
|
|
|
2009-08-11 14:51:38 +04:00
|
|
|
return $this->_attributes['namedNativeQueries'][$name];
|
|
|
|
}
|
2010-03-05 19:35:00 +03:00
|
|
|
|
2009-10-15 00:18:36 +04:00
|
|
|
/**
|
|
|
|
* Ensures that this Configuration instance contains settings that are
|
|
|
|
* suitable for a production environment.
|
2010-03-05 19:35:00 +03:00
|
|
|
*
|
2012-12-01 20:28:06 +04:00
|
|
|
* @return void
|
|
|
|
*
|
2010-03-05 19:35:00 +03:00
|
|
|
* @throws ORMException If a configuration setting has a value that is not
|
|
|
|
* suitable for a production environment.
|
2009-10-15 00:18:36 +04:00
|
|
|
*/
|
|
|
|
public function ensureProductionSettings()
|
|
|
|
{
|
2014-12-19 22:18:45 +03:00
|
|
|
$queryCacheImpl = $this->getQueryCacheImpl();
|
|
|
|
|
|
|
|
if ( ! $queryCacheImpl) {
|
2010-03-03 04:30:00 +03:00
|
|
|
throw ORMException::queryCacheNotConfigured();
|
2009-10-15 00:18:36 +04:00
|
|
|
}
|
2012-03-15 09:08:28 +04:00
|
|
|
|
2014-12-19 22:18:45 +03:00
|
|
|
if ($queryCacheImpl instanceof ArrayCache) {
|
|
|
|
throw ORMException::queryCacheUsesNonPersistentCache($queryCacheImpl);
|
|
|
|
}
|
|
|
|
|
2014-11-11 09:35:52 +03:00
|
|
|
$metadataCacheImpl = $this->getMetadataCacheImpl();
|
|
|
|
|
|
|
|
if ( ! $metadataCacheImpl) {
|
2010-03-03 04:30:00 +03:00
|
|
|
throw ORMException::metadataCacheNotConfigured();
|
2009-10-15 00:18:36 +04:00
|
|
|
}
|
2014-11-11 09:35:52 +03:00
|
|
|
|
|
|
|
if ($metadataCacheImpl instanceof ArrayCache) {
|
|
|
|
throw ORMException::metadataCacheUsesNonPersistentCache($metadataCacheImpl);
|
2014-11-08 17:05:56 +03:00
|
|
|
}
|
2012-03-15 09:08:28 +04:00
|
|
|
|
2010-07-02 02:36:31 +04:00
|
|
|
if ($this->getAutoGenerateProxyClasses()) {
|
2010-03-03 04:30:00 +03:00
|
|
|
throw ORMException::proxyClassesAlwaysRegenerating();
|
2009-10-15 00:18:36 +04:00
|
|
|
}
|
|
|
|
}
|
2010-03-15 20:19:00 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Registers a custom DQL function that produces a string value.
|
|
|
|
* Such a function can then be used in any DQL statement in any place where string
|
|
|
|
* functions are allowed.
|
|
|
|
*
|
2010-04-15 22:14:03 +04:00
|
|
|
* DQL function names are case-insensitive.
|
|
|
|
*
|
2014-05-16 11:32:52 +04:00
|
|
|
* @param string $name Function name.
|
|
|
|
* @param string|callable $className Class name or a callable that returns the function.
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*
|
2012-07-08 16:58:06 +04:00
|
|
|
* @throws ORMException
|
2010-03-15 20:19:00 +03:00
|
|
|
*/
|
|
|
|
public function addCustomStringFunction($name, $className)
|
|
|
|
{
|
2012-07-05 23:52:40 +04:00
|
|
|
if (Query\Parser::isInternalFunction($name)) {
|
|
|
|
throw ORMException::overwriteInternalDQLFunctionNotAllowed($name);
|
|
|
|
}
|
|
|
|
|
2010-03-15 20:19:00 +03:00
|
|
|
$this->_attributes['customStringFunctions'][strtolower($name)] = $className;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the implementation class name of a registered custom string DQL function.
|
2011-08-05 18:48:05 +04:00
|
|
|
*
|
2010-03-15 20:19:00 +03:00
|
|
|
* @param string $name
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
|
|
|
* @return string|null
|
2010-03-15 20:19:00 +03:00
|
|
|
*/
|
|
|
|
public function getCustomStringFunction($name)
|
|
|
|
{
|
2010-04-15 22:14:03 +04:00
|
|
|
$name = strtolower($name);
|
2012-03-15 09:08:28 +04:00
|
|
|
|
|
|
|
return isset($this->_attributes['customStringFunctions'][$name])
|
|
|
|
? $this->_attributes['customStringFunctions'][$name]
|
|
|
|
: null;
|
2010-03-15 20:19:00 +03:00
|
|
|
}
|
|
|
|
|
2010-04-15 06:27:33 +04:00
|
|
|
/**
|
2010-04-15 13:55:03 +04:00
|
|
|
* Sets a map of custom DQL string functions.
|
|
|
|
*
|
|
|
|
* Keys must be function names and values the FQCN of the implementing class.
|
|
|
|
* The function names will be case-insensitive in DQL.
|
|
|
|
*
|
|
|
|
* Any previously added string functions are discarded.
|
2010-04-15 06:27:33 +04:00
|
|
|
*
|
2010-04-15 13:55:03 +04:00
|
|
|
* @param array $functions The map of custom DQL string functions.
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
|
|
|
* @return void
|
2010-04-15 06:27:33 +04:00
|
|
|
*/
|
2010-04-15 13:55:03 +04:00
|
|
|
public function setCustomStringFunctions(array $functions)
|
2010-04-15 06:27:33 +04:00
|
|
|
{
|
2012-07-05 23:52:40 +04:00
|
|
|
foreach ($functions as $name => $className) {
|
|
|
|
$this->addCustomStringFunction($name, $className);
|
|
|
|
}
|
2010-04-15 06:27:33 +04:00
|
|
|
}
|
|
|
|
|
2010-03-15 20:19:00 +03:00
|
|
|
/**
|
|
|
|
* Registers a custom DQL function that produces a numeric value.
|
|
|
|
* Such a function can then be used in any DQL statement in any place where numeric
|
|
|
|
* functions are allowed.
|
|
|
|
*
|
2010-04-15 22:14:03 +04:00
|
|
|
* DQL function names are case-insensitive.
|
|
|
|
*
|
2014-05-16 11:32:52 +04:00
|
|
|
* @param string $name Function name.
|
|
|
|
* @param string|callable $className Class name or a callable that returns the function.
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*
|
2012-07-08 16:58:06 +04:00
|
|
|
* @throws ORMException
|
2010-03-15 20:19:00 +03:00
|
|
|
*/
|
|
|
|
public function addCustomNumericFunction($name, $className)
|
|
|
|
{
|
2012-07-05 23:52:40 +04:00
|
|
|
if (Query\Parser::isInternalFunction($name)) {
|
|
|
|
throw ORMException::overwriteInternalDQLFunctionNotAllowed($name);
|
|
|
|
}
|
|
|
|
|
2010-03-15 20:19:00 +03:00
|
|
|
$this->_attributes['customNumericFunctions'][strtolower($name)] = $className;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the implementation class name of a registered custom numeric DQL function.
|
2011-08-05 18:48:05 +04:00
|
|
|
*
|
2010-03-15 20:19:00 +03:00
|
|
|
* @param string $name
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
|
|
|
* @return string|null
|
2010-03-15 20:19:00 +03:00
|
|
|
*/
|
|
|
|
public function getCustomNumericFunction($name)
|
|
|
|
{
|
2010-04-15 22:14:03 +04:00
|
|
|
$name = strtolower($name);
|
2012-03-15 09:08:28 +04:00
|
|
|
|
|
|
|
return isset($this->_attributes['customNumericFunctions'][$name])
|
|
|
|
? $this->_attributes['customNumericFunctions'][$name]
|
|
|
|
: null;
|
2010-03-15 20:19:00 +03:00
|
|
|
}
|
|
|
|
|
2010-04-15 06:27:33 +04:00
|
|
|
/**
|
2010-04-15 13:55:03 +04:00
|
|
|
* Sets a map of custom DQL numeric functions.
|
|
|
|
*
|
|
|
|
* Keys must be function names and values the FQCN of the implementing class.
|
|
|
|
* The function names will be case-insensitive in DQL.
|
2010-04-15 06:27:33 +04:00
|
|
|
*
|
2010-04-15 13:55:03 +04:00
|
|
|
* Any previously added numeric functions are discarded.
|
|
|
|
*
|
|
|
|
* @param array $functions The map of custom DQL numeric functions.
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
|
|
|
* @return void
|
2010-04-15 06:27:33 +04:00
|
|
|
*/
|
2010-04-15 13:55:03 +04:00
|
|
|
public function setCustomNumericFunctions(array $functions)
|
2010-04-15 06:27:33 +04:00
|
|
|
{
|
2012-07-05 23:52:40 +04:00
|
|
|
foreach ($functions as $name => $className) {
|
|
|
|
$this->addCustomNumericFunction($name, $className);
|
|
|
|
}
|
2010-04-15 06:27:33 +04:00
|
|
|
}
|
|
|
|
|
2010-03-15 20:19:00 +03:00
|
|
|
/**
|
|
|
|
* Registers a custom DQL function that produces a date/time value.
|
|
|
|
* Such a function can then be used in any DQL statement in any place where date/time
|
|
|
|
* functions are allowed.
|
|
|
|
*
|
2010-04-15 22:14:03 +04:00
|
|
|
* DQL function names are case-insensitive.
|
|
|
|
*
|
2014-05-16 11:32:52 +04:00
|
|
|
* @param string $name Function name.
|
|
|
|
* @param string|callable $className Class name or a callable that returns the function.
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*
|
2012-07-08 16:58:06 +04:00
|
|
|
* @throws ORMException
|
2010-03-15 20:19:00 +03:00
|
|
|
*/
|
|
|
|
public function addCustomDatetimeFunction($name, $className)
|
|
|
|
{
|
2012-07-05 23:52:40 +04:00
|
|
|
if (Query\Parser::isInternalFunction($name)) {
|
|
|
|
throw ORMException::overwriteInternalDQLFunctionNotAllowed($name);
|
|
|
|
}
|
|
|
|
|
2010-03-15 20:19:00 +03:00
|
|
|
$this->_attributes['customDatetimeFunctions'][strtolower($name)] = $className;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the implementation class name of a registered custom date/time DQL function.
|
2011-08-05 18:48:05 +04:00
|
|
|
*
|
2010-03-15 20:19:00 +03:00
|
|
|
* @param string $name
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
|
|
|
* @return string|null
|
2010-03-15 20:19:00 +03:00
|
|
|
*/
|
|
|
|
public function getCustomDatetimeFunction($name)
|
|
|
|
{
|
2010-04-15 22:14:03 +04:00
|
|
|
$name = strtolower($name);
|
2012-03-15 09:08:28 +04:00
|
|
|
|
|
|
|
return isset($this->_attributes['customDatetimeFunctions'][$name])
|
|
|
|
? $this->_attributes['customDatetimeFunctions'][$name]
|
|
|
|
: null;
|
2010-03-15 20:19:00 +03:00
|
|
|
}
|
2010-04-15 06:27:33 +04:00
|
|
|
|
|
|
|
/**
|
2010-04-15 13:55:03 +04:00
|
|
|
* Sets a map of custom DQL date/time functions.
|
|
|
|
*
|
|
|
|
* Keys must be function names and values the FQCN of the implementing class.
|
|
|
|
* The function names will be case-insensitive in DQL.
|
|
|
|
*
|
|
|
|
* Any previously added date/time functions are discarded.
|
|
|
|
*
|
|
|
|
* @param array $functions The map of custom DQL date/time functions.
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
|
|
|
* @return void
|
2010-04-15 06:27:33 +04:00
|
|
|
*/
|
2010-04-15 13:55:03 +04:00
|
|
|
public function setCustomDatetimeFunctions(array $functions)
|
2010-04-15 06:27:33 +04:00
|
|
|
{
|
2012-07-05 23:52:40 +04:00
|
|
|
foreach ($functions as $name => $className) {
|
|
|
|
$this->addCustomDatetimeFunction($name, $className);
|
|
|
|
}
|
2010-04-15 06:27:33 +04:00
|
|
|
}
|
2010-06-03 07:25:09 +04:00
|
|
|
|
2012-08-14 14:12:10 +04:00
|
|
|
/**
|
2012-12-13 21:56:25 +04:00
|
|
|
* Sets the custom hydrator modes in one pass.
|
2012-08-14 14:12:10 +04:00
|
|
|
*
|
2012-12-01 20:28:06 +04:00
|
|
|
* @param array $modes An array of ($modeName => $hydrator).
|
|
|
|
*
|
|
|
|
* @return void
|
2012-08-14 14:12:10 +04:00
|
|
|
*/
|
|
|
|
public function setCustomHydrationModes($modes)
|
|
|
|
{
|
2012-08-15 00:43:32 +04:00
|
|
|
$this->_attributes['customHydrationModes'] = array();
|
2012-08-14 14:12:10 +04:00
|
|
|
|
|
|
|
foreach ($modes as $modeName => $hydrator) {
|
|
|
|
$this->addCustomHydrationMode($modeName, $hydrator);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-03 07:25:09 +04:00
|
|
|
/**
|
2012-12-13 21:56:25 +04:00
|
|
|
* Gets the hydrator class for the given hydration mode name.
|
2010-06-03 07:25:09 +04:00
|
|
|
*
|
2010-06-03 22:11:31 +04:00
|
|
|
* @param string $modeName The hydration mode name.
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
|
|
|
* @return string|null The hydrator class name.
|
2010-06-03 07:25:09 +04:00
|
|
|
*/
|
2010-06-03 22:11:31 +04:00
|
|
|
public function getCustomHydrationMode($modeName)
|
2010-06-03 07:25:09 +04:00
|
|
|
{
|
2012-03-15 09:08:28 +04:00
|
|
|
return isset($this->_attributes['customHydrationModes'][$modeName])
|
|
|
|
? $this->_attributes['customHydrationModes'][$modeName]
|
|
|
|
: null;
|
2010-06-03 07:25:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-12-13 21:56:25 +04:00
|
|
|
* Adds a custom hydration mode.
|
2010-06-03 07:25:09 +04:00
|
|
|
*
|
2010-06-03 22:11:31 +04:00
|
|
|
* @param string $modeName The hydration mode name.
|
|
|
|
* @param string $hydrator The hydrator class name.
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
|
|
|
* @return void
|
2010-06-03 07:25:09 +04:00
|
|
|
*/
|
2010-06-03 22:11:31 +04:00
|
|
|
public function addCustomHydrationMode($modeName, $hydrator)
|
2010-06-03 07:25:09 +04:00
|
|
|
{
|
2010-06-03 22:11:31 +04:00
|
|
|
$this->_attributes['customHydrationModes'][$modeName] = $hydrator;
|
2010-06-03 07:25:09 +04:00
|
|
|
}
|
2010-11-27 22:53:26 +03:00
|
|
|
|
|
|
|
/**
|
2012-12-13 21:56:25 +04:00
|
|
|
* Sets a class metadata factory.
|
2011-08-05 18:48:05 +04:00
|
|
|
*
|
2012-07-08 16:58:06 +04:00
|
|
|
* @param string $cmfName
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
|
|
|
* @return void
|
2010-11-27 22:53:26 +03:00
|
|
|
*/
|
|
|
|
public function setClassMetadataFactoryName($cmfName)
|
|
|
|
{
|
|
|
|
$this->_attributes['classMetadataFactoryName'] = $cmfName;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getClassMetadataFactoryName()
|
|
|
|
{
|
2012-03-15 09:08:28 +04:00
|
|
|
if ( ! isset($this->_attributes['classMetadataFactoryName'])) {
|
2010-11-27 22:53:26 +03:00
|
|
|
$this->_attributes['classMetadataFactoryName'] = 'Doctrine\ORM\Mapping\ClassMetadataFactory';
|
|
|
|
}
|
2012-03-15 09:08:28 +04:00
|
|
|
|
2010-11-27 22:53:26 +03:00
|
|
|
return $this->_attributes['classMetadataFactoryName'];
|
|
|
|
}
|
2011-07-22 14:01:33 +04:00
|
|
|
|
2011-12-06 00:14:31 +04:00
|
|
|
/**
|
2012-12-13 21:56:25 +04:00
|
|
|
* Adds a filter to the list of possible filters.
|
2011-12-06 00:14:31 +04:00
|
|
|
*
|
2013-02-09 23:27:39 +04:00
|
|
|
* @param string $name The name of the filter.
|
|
|
|
* @param string $className The class name of the filter.
|
2011-12-06 00:14:31 +04:00
|
|
|
*/
|
2013-02-09 23:27:39 +04:00
|
|
|
public function addFilter($name, $className)
|
2011-07-22 14:01:33 +04:00
|
|
|
{
|
2013-02-09 23:27:39 +04:00
|
|
|
$this->_attributes['filters'][$name] = $className;
|
2011-07-22 14:01:33 +04:00
|
|
|
}
|
|
|
|
|
2011-12-06 00:14:31 +04:00
|
|
|
/**
|
|
|
|
* Gets the class name for a given filter name.
|
|
|
|
*
|
|
|
|
* @param string $name The name of the filter.
|
|
|
|
*
|
2015-05-07 15:05:20 +03:00
|
|
|
* @return string The class name of the filter, or null if it is not
|
2013-02-09 23:27:39 +04:00
|
|
|
* defined.
|
2011-12-06 00:14:31 +04:00
|
|
|
*/
|
2013-02-09 23:27:39 +04:00
|
|
|
public function getFilterClassName($name)
|
2011-07-22 14:01:33 +04:00
|
|
|
{
|
2012-03-15 09:08:28 +04:00
|
|
|
return isset($this->_attributes['filters'][$name])
|
|
|
|
? $this->_attributes['filters'][$name]
|
|
|
|
: null;
|
2011-07-22 14:01:33 +04:00
|
|
|
}
|
2011-10-14 14:33:39 +04:00
|
|
|
|
2011-09-08 21:36:13 +04:00
|
|
|
/**
|
2012-12-13 21:56:25 +04:00
|
|
|
* Sets default repository class.
|
2011-12-20 01:56:19 +04:00
|
|
|
*
|
2011-09-08 21:36:13 +04:00
|
|
|
* @since 2.2
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
2011-09-08 21:36:13 +04:00
|
|
|
* @param string $className
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*
|
2012-07-25 09:23:52 +04:00
|
|
|
* @throws ORMException If not is a \Doctrine\Common\Persistence\ObjectRepository
|
2011-09-08 21:36:13 +04:00
|
|
|
*/
|
|
|
|
public function setDefaultRepositoryClassName($className)
|
|
|
|
{
|
2012-07-26 23:50:51 +04:00
|
|
|
$reflectionClass = new \ReflectionClass($className);
|
2012-03-15 09:08:28 +04:00
|
|
|
|
2012-07-26 23:50:51 +04:00
|
|
|
if ( ! $reflectionClass->implementsInterface('Doctrine\Common\Persistence\ObjectRepository')) {
|
2011-09-09 00:21:06 +04:00
|
|
|
throw ORMException::invalidEntityRepository($className);
|
2011-09-08 21:36:13 +04:00
|
|
|
}
|
2012-03-15 09:08:28 +04:00
|
|
|
|
2011-09-08 21:36:13 +04:00
|
|
|
$this->_attributes['defaultRepositoryClassName'] = $className;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get default repository class.
|
2011-12-20 01:56:19 +04:00
|
|
|
*
|
2011-09-08 21:36:13 +04:00
|
|
|
* @since 2.2
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
2011-09-08 21:36:13 +04:00
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getDefaultRepositoryClassName()
|
|
|
|
{
|
2012-03-15 09:08:28 +04:00
|
|
|
return isset($this->_attributes['defaultRepositoryClassName'])
|
|
|
|
? $this->_attributes['defaultRepositoryClassName']
|
|
|
|
: 'Doctrine\ORM\EntityRepository';
|
2011-09-08 21:36:13 +04:00
|
|
|
}
|
2011-12-23 20:41:03 +04:00
|
|
|
|
|
|
|
/**
|
2012-12-13 21:56:25 +04:00
|
|
|
* Sets naming strategy.
|
2011-12-23 20:41:03 +04:00
|
|
|
*
|
|
|
|
* @since 2.3
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
2011-12-23 20:41:03 +04:00
|
|
|
* @param NamingStrategy $namingStrategy
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
|
|
|
* @return void
|
2011-12-23 20:41:03 +04:00
|
|
|
*/
|
|
|
|
public function setNamingStrategy(NamingStrategy $namingStrategy)
|
|
|
|
{
|
|
|
|
$this->_attributes['namingStrategy'] = $namingStrategy;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-12-13 21:56:25 +04:00
|
|
|
* Gets naming strategy..
|
2011-12-23 20:41:03 +04:00
|
|
|
*
|
|
|
|
* @since 2.3
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
2011-12-23 20:41:03 +04:00
|
|
|
* @return NamingStrategy
|
|
|
|
*/
|
|
|
|
public function getNamingStrategy()
|
|
|
|
{
|
2012-03-15 09:08:28 +04:00
|
|
|
if ( ! isset($this->_attributes['namingStrategy'])) {
|
2011-12-23 20:41:03 +04:00
|
|
|
$this->_attributes['namingStrategy'] = new DefaultNamingStrategy();
|
|
|
|
}
|
2012-07-08 16:58:06 +04:00
|
|
|
|
2011-12-23 20:41:03 +04:00
|
|
|
return $this->_attributes['namingStrategy'];
|
|
|
|
}
|
2012-05-11 04:18:09 +04:00
|
|
|
|
|
|
|
/**
|
2012-12-13 21:56:25 +04:00
|
|
|
* Sets quote strategy.
|
2012-05-11 04:18:09 +04:00
|
|
|
*
|
2012-06-04 22:16:20 +04:00
|
|
|
* @since 2.3
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
2012-09-21 03:20:06 +04:00
|
|
|
* @param \Doctrine\ORM\Mapping\QuoteStrategy $quoteStrategy
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
|
|
|
* @return void
|
2012-05-11 04:18:09 +04:00
|
|
|
*/
|
2012-06-12 03:14:17 +04:00
|
|
|
public function setQuoteStrategy(QuoteStrategy $quoteStrategy)
|
2012-05-11 04:18:09 +04:00
|
|
|
{
|
2012-06-12 16:47:40 +04:00
|
|
|
$this->_attributes['quoteStrategy'] = $quoteStrategy;
|
2012-05-11 04:18:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-12-13 21:56:25 +04:00
|
|
|
* Gets quote strategy.
|
2012-05-11 04:18:09 +04:00
|
|
|
*
|
2012-06-04 22:16:20 +04:00
|
|
|
* @since 2.3
|
2012-12-01 20:28:06 +04:00
|
|
|
*
|
2012-09-21 03:20:06 +04:00
|
|
|
* @return \Doctrine\ORM\Mapping\QuoteStrategy
|
2012-05-11 04:18:09 +04:00
|
|
|
*/
|
2012-06-12 03:14:17 +04:00
|
|
|
public function getQuoteStrategy()
|
2012-05-11 04:18:09 +04:00
|
|
|
{
|
2012-06-12 03:14:17 +04:00
|
|
|
if ( ! isset($this->_attributes['quoteStrategy'])) {
|
2012-06-13 00:47:00 +04:00
|
|
|
$this->_attributes['quoteStrategy'] = new DefaultQuoteStrategy();
|
2012-06-12 03:14:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return $this->_attributes['quoteStrategy'];
|
2012-05-11 04:18:09 +04:00
|
|
|
}
|
2012-08-13 05:10:47 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the entity listener resolver.
|
|
|
|
*
|
|
|
|
* @since 2.4
|
|
|
|
* @param \Doctrine\ORM\Mapping\EntityListenerResolver $resolver
|
|
|
|
*/
|
|
|
|
public function setEntityListenerResolver(EntityListenerResolver $resolver)
|
|
|
|
{
|
|
|
|
$this->_attributes['entityListenerResolver'] = $resolver;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the entity listener resolver.
|
|
|
|
*
|
|
|
|
* @since 2.4
|
|
|
|
* @return \Doctrine\ORM\Mapping\EntityListenerResolver
|
|
|
|
*/
|
|
|
|
public function getEntityListenerResolver()
|
|
|
|
{
|
|
|
|
if ( ! isset($this->_attributes['entityListenerResolver'])) {
|
|
|
|
$this->_attributes['entityListenerResolver'] = new DefaultEntityListenerResolver();
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->_attributes['entityListenerResolver'];
|
|
|
|
}
|
2013-06-14 05:47:40 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the entity repository factory.
|
|
|
|
*
|
2013-06-14 20:07:28 +04:00
|
|
|
* @since 2.4
|
2013-06-14 07:31:18 +04:00
|
|
|
* @param \Doctrine\ORM\Repository\RepositoryFactory $repositoryFactory
|
2013-06-14 05:47:40 +04:00
|
|
|
*/
|
2013-06-14 07:31:18 +04:00
|
|
|
public function setRepositoryFactory(RepositoryFactory $repositoryFactory)
|
2013-06-14 05:47:40 +04:00
|
|
|
{
|
|
|
|
$this->_attributes['repositoryFactory'] = $repositoryFactory;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the entity repository factory.
|
|
|
|
*
|
2013-06-14 20:07:28 +04:00
|
|
|
* @since 2.4
|
2013-06-14 07:31:18 +04:00
|
|
|
* @return \Doctrine\ORM\Repository\RepositoryFactory
|
2013-06-14 05:47:40 +04:00
|
|
|
*/
|
|
|
|
public function getRepositoryFactory()
|
|
|
|
{
|
|
|
|
return isset($this->_attributes['repositoryFactory'])
|
|
|
|
? $this->_attributes['repositoryFactory']
|
|
|
|
: new DefaultRepositoryFactory();
|
|
|
|
}
|
2013-10-03 21:55:55 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @since 2.5
|
|
|
|
*
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public function isSecondLevelCacheEnabled()
|
|
|
|
{
|
|
|
|
return isset($this->_attributes['isSecondLevelCacheEnabled'])
|
|
|
|
? $this->_attributes['isSecondLevelCacheEnabled']
|
|
|
|
: false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @since 2.5
|
|
|
|
*
|
|
|
|
* @param boolean $flag
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function setSecondLevelCacheEnabled($flag = true)
|
|
|
|
{
|
|
|
|
$this->_attributes['isSecondLevelCacheEnabled'] = (boolean) $flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @since 2.5
|
|
|
|
*
|
|
|
|
* @param \Doctrine\ORM\Cache\CacheConfiguration $cacheConfig
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function setSecondLevelCacheConfiguration(CacheConfiguration $cacheConfig)
|
|
|
|
{
|
|
|
|
$this->_attributes['secondLevelCacheConfiguration'] = $cacheConfig;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @since 2.5
|
|
|
|
*
|
|
|
|
* @return \Doctrine\ORM\Cache\CacheConfiguration|null
|
|
|
|
*/
|
|
|
|
public function getSecondLevelCacheConfiguration()
|
|
|
|
{
|
|
|
|
if ( ! isset($this->_attributes['secondLevelCacheConfiguration']) && $this->isSecondLevelCacheEnabled()) {
|
|
|
|
$this->_attributes['secondLevelCacheConfiguration'] = new CacheConfiguration();
|
|
|
|
}
|
|
|
|
|
|
|
|
return isset($this->_attributes['secondLevelCacheConfiguration'])
|
|
|
|
? $this->_attributes['secondLevelCacheConfiguration']
|
|
|
|
: null;
|
|
|
|
}
|
2013-11-27 09:24:09 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns query hints, which will be applied to every query in application
|
|
|
|
*
|
|
|
|
* @since 2.5
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getDefaultQueryHints()
|
|
|
|
{
|
|
|
|
return isset($this->_attributes['defaultQueryHints']) ? $this->_attributes['defaultQueryHints'] : array();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets array of query hints, which will be applied to every query in application
|
|
|
|
*
|
|
|
|
* @since 2.5
|
|
|
|
*
|
|
|
|
* @param array $defaultQueryHints
|
|
|
|
*/
|
|
|
|
public function setDefaultQueryHints(array $defaultQueryHints)
|
|
|
|
{
|
|
|
|
$this->_attributes['defaultQueryHints'] = $defaultQueryHints;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the value of a default query hint. If the hint name is not recognized, FALSE is returned.
|
|
|
|
*
|
|
|
|
* @since 2.5
|
|
|
|
*
|
|
|
|
* @param string $name The name of the hint.
|
|
|
|
*
|
|
|
|
* @return mixed The value of the hint or FALSE, if the hint name is not recognized.
|
|
|
|
*/
|
|
|
|
public function getDefaultQueryHint($name)
|
|
|
|
{
|
|
|
|
return isset($this->_attributes['defaultQueryHints'][$name])
|
|
|
|
? $this->_attributes['defaultQueryHints'][$name]
|
|
|
|
: false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-11-27 09:26:26 +04:00
|
|
|
* Sets a default query hint. If the hint name is not recognized, it is silently ignored.
|
2013-11-27 09:24:09 +04:00
|
|
|
*
|
|
|
|
* @since 2.5
|
|
|
|
*
|
|
|
|
* @param string $name The name of the hint.
|
|
|
|
* @param mixed $value The value of the hint.
|
|
|
|
*/
|
|
|
|
public function setDefaultQueryHint($name, $value)
|
|
|
|
{
|
|
|
|
$this->_attributes['defaultQueryHints'][$name] = $value;
|
|
|
|
}
|
2011-07-22 14:01:33 +04:00
|
|
|
}
|