Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

266 lines (241 sloc) 8.052 kB
<?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\ODM\PHPCR;
use Doctrine\Common\Cache\Cache;
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver;
use Doctrine\ODM\PHPCR\Mapping\Driver\BuiltinDocumentsDriver;
use Doctrine\ODM\PHPCR\DocumentClassMapperInterface;
use Doctrine\ODM\PHPCR\DocumentClassMapper;
/**
* Configuration class
*
* @license http://www.opensource.org/licenses/MIT-license.php MIT license
* @link www.doctrine-project.com
* @since 1.0
* @author Jordi Boggiano <j.boggiano@seld.be>
* @author Pascal Helfenstein <nicam@nicam.ch>
*/
class Configuration
{
/**
* Array of attributes for this configuration instance.
*
* @var array $attributes
*/
private $attributes = array(
'writeDoctrineMetadata' => true,
'validateDoctrineMetadata' => true,
'metadataDriverImpl' => null,
'metadataCacheImpl' => null,
'documentClassMapper' => null,
'proxyNamespace' => 'MyPHPCRProxyNS',
'autoGenerateProxyClasses' => true,
);
/**
* Sets if all PHPCR document metadata should be validated on read
*
* @param boolean $validateDoctrineMetadata
*/
public function setValidateDoctrineMetadata($validateDoctrineMetadata)
{
$this->attributes['validateDoctrineMetadata'] = $validateDoctrineMetadata;
}
/**
* Gets if all PHPCR document metadata should be validated on read
*
* @return boolean
*/
public function getValidateDoctrineMetadata()
{
return $this->attributes['validateDoctrineMetadata'];
}
/**
* Sets if all PHPCR documents should automatically get doctrine metadata added on write
*
* @param boolean $writeDoctrineMetadata
*/
public function setWriteDoctrineMetadata($writeDoctrineMetadata)
{
$this->attributes['writeDoctrineMetadata'] = $writeDoctrineMetadata;
}
/**
* Gets if all PHPCR documents should automatically get doctrine metadata added on write
*
* @return boolean
*/
public function getWriteDoctrineMetadata()
{
return $this->attributes['writeDoctrineMetadata'];
}
/**
* Adds a namespace under a certain alias.
*
* @param string $alias
* @param string $namespace
*/
public function addDocumentNamespace($alias, $namespace)
{
$this->attributes['documentNamespaces'][$alias] = $namespace;
}
/**
* Resolves a registered namespace alias to the full namespace.
*
* @param string $documentNamespaceAlias
* @return string
* @throws PHPCRException
*/
public function getDocumentNamespace($documentNamespaceAlias)
{
if (!isset($this->attributes['documentNamespaces'][$documentNamespaceAlias])) {
throw PHPCRException::unknownDocumentNamespace($documentNamespaceAlias);
}
return trim($this->attributes['documentNamespaces'][$documentNamespaceAlias], '\\');
}
/**
* Set the document alias map
*
* @param array $documentAliasMap
* @return void
*/
public function setDocumentNamespaces(array $documentNamespaces)
{
$this->attributes['documentNamespaces'] = $documentNamespaces;
}
/**
* Sets the driver implementation that is used to retrieve mapping metadata.
*
* @param MappingDriver $driverImpl
* @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).
*/
public function setMetadataDriverImpl(MappingDriver $driverImpl, $useBuildInDocumentsDriver = true)
{
if ($useBuildInDocumentsDriver) {
$driverImpl = new BuiltinDocumentsDriver($driverImpl);
}
$this->attributes['metadataDriverImpl'] = $driverImpl;
}
/**
* Gets the driver implementation that is used to retrieve mapping metadata.
*
* @return MappingDriver
*/
public function getMetadataDriverImpl()
{
return $this->attributes['metadataDriverImpl'];
}
/**
* Sets the cache driver implementation that is used for metadata caching.
*
* @param Cache $metadataCacheImpl
*/
public function setMetadataCacheImpl(Cache $metadataCacheImpl)
{
$this->attributes['metadataCacheImpl'] = $metadataCacheImpl;
}
/**
* Gets the cache driver implementation that is used for the mapping metadata.
*
* @return Cache|null
*/
public function getMetadataCacheImpl()
{
return $this->attributes['metadataCacheImpl'];
}
/**
* Gets the cache driver implementation that is used for metadata caching.
*
* @return \Doctrine\ODM\PHPCR\DocumentClassMapperInterface
*/
public function getDocumentClassMapper()
{
if (empty($this->attributes['documentClassMapper'])) {
$this->setDocumentClassMapper(new DocumentClassMapper());
}
return $this->attributes['documentClassMapper'];
}
/**
* Sets the cache driver implementation that is used for metadata caching.
*
* @param \Doctrine\ODM\PHPCR\DocumentClassMapperInterface $documentClassMapper
*/
public function setDocumentClassMapper(DocumentClassMapperInterface $documentClassMapper)
{
$this->attributes['documentClassMapper'] = $documentClassMapper;
}
/**
* Sets the directory where Doctrine generates any necessary proxy class files.
*
* @param string $dir
*/
public function setProxyDir($dir)
{
$this->attributes['proxyDir'] = $dir;
}
/**
* Gets the directory where Doctrine generates any necessary proxy class files.
*
* @return string
*/
public function getProxyDir()
{
if (!isset($this->attributes['proxyDir'])) {
$this->attributes['proxyDir'] = \sys_get_temp_dir();
}
return $this->attributes['proxyDir'];
}
/**
* Sets the namespace for Doctrine proxy class files.
*
* @param string $namespace
*/
public function setProxyNamespace($namespace)
{
$this->attributes['proxyNamespace'] = $namespace;
}
/**
* Gets the namespace for Doctrine proxy class files.
*
* @return string
*/
public function getProxyNamespace()
{
return $this->attributes['proxyNamespace'];
}
/**
* Sets a boolean flag that indicates whether proxy classes should always be regenerated
* during each script execution.
*
* @param boolean $bool
*/
public function setAutoGenerateProxyClasses($bool)
{
$this->attributes['autoGenerateProxyClasses'] = $bool;
}
/**
* Gets a boolean flag that indicates whether proxy classes should always be regenerated
* during each script execution.
*
* @return boolean
*/
public function getAutoGenerateProxyClasses()
{
return $this->attributes['autoGenerateProxyClasses'];
}
}
Jump to Line
Something went wrong with that request. Please try again.