Skip to content

Commit

Permalink
Initial import of the code
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Dec 6, 2010
1 parent e051018 commit 9cada55
Show file tree
Hide file tree
Showing 63 changed files with 6,240 additions and 0 deletions.
502 changes: 502 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
PHPCR ODM for Doctrine2
=======================

Current Status
--------------

* (very) basic CRUD is implemented
* metadata reading implemented for annotations

Todo
----

* fix the tests that fail
* implement metadata reading for xml/yml/php
* figure out how we can do relations in a sane way
* add metadata "node" to allow injecting the jackalope node object into documents
* implement Sf2 bundle

Notes
-----

* The type of the document is stored in each node (stored as _doctrine_alias for the moment)
238 changes: 238 additions & 0 deletions lib/Doctrine/ODM/PHPCR/Configuration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
<?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 LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\ODM\PHPCR;

use Doctrine\ODM\PHPCR\HTTP\Client;
use Doctrine\ODM\PHPCR\Mapping\Driver\Driver;
use Doctrine\Common\Cache\Cache;

/**
* Configuration class
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @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,
'proxyNamespace' => 'MyPHPCRProxyNS',
);

/**
* 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'];
}

public function setPhpcrSession(\PHPCR\SessionInterface $session)
{
$this->attributes['phpcrSession'] = $session;
}

public function getPhpcrSession()
{
return isset($this->attributes['phpcrSession']) ?
$this->attributes['phpcrSession'] : null;
}

/**
* 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 cache driver implementation that is used for metadata caching.
*
* @param Driver $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(Driver $driverImpl)
{
$this->attributes['metadataDriverImpl'] = $driverImpl;
}

/**
* Add a new default annotation driver with a correctly configured annotation reader.
*
* @param array $paths
* @return Mapping\Driver\AnnotationDriver
*/
public function newDefaultAnnotationDriver($paths = array())
{
$reader = new \Doctrine\Common\Annotations\AnnotationReader();
$reader->setDefaultAnnotationNamespace('Doctrine\ODM\PHPCR\Mapping\\');

return new \Doctrine\ODM\PHPCR\Mapping\Driver\AnnotationDriver($reader, (array) $paths);
}

/**
* Gets the cache driver implementation that is used for the mapping metadata.
*
* @return Mapping\Driver\Driver
*/
public function getMetadataDriverImpl()
{
return isset($this->attributes['metadataDriverImpl']) ?
$this->attributes['metadataDriverImpl'] : null;
}

/**
* Gets the cache driver implementation that is used for metadata caching.
*
* @return \Doctrine\Common\Cache\Cache
*/
public function getMetadataCacheImpl()
{
return isset($this->attributes['metadataCacheImpl']) ?
$this->attributes['metadataCacheImpl'] : null;
}

/**
* Sets the cache driver implementation that is used for metadata caching.
*
* @param \Doctrine\Common\Cache\Cache $cacheImpl
*/
public function setMetadataCacheImpl(Cache $cacheImpl)
{
$this->attributes['metadataCacheImpl'] = $cacheImpl;
}

/**
* 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'];
}
}
Loading

0 comments on commit 9cada55

Please sign in to comment.