forked from doctrine/phpcr-odm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
63 changed files
with
6,240 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']; | ||
} | ||
} |
Oops, something went wrong.