Permalink
Browse files

Initial import of the code

  • Loading branch information...
1 parent e051018 commit 9cada5567c6a29302d919b2f414d9cf2ae9d2dd3 @Seldaek Seldaek committed Dec 6, 2010
Showing with 6,240 additions and 0 deletions.
  1. +502 −0 LICENSE
  2. +22 −0 README.markdown
  3. +238 −0 lib/Doctrine/ODM/PHPCR/Configuration.php
  4. +276 −0 lib/Doctrine/ODM/PHPCR/DocumentManager.php
  5. +36 −0 lib/Doctrine/ODM/PHPCR/DocumentNotFoundException.php
  6. +122 −0 lib/Doctrine/ODM/PHPCR/DocumentRepository.php
  7. +33 −0 lib/Doctrine/ODM/PHPCR/Event.php
  8. +50 −0 lib/Doctrine/ODM/PHPCR/Events/LifecycleEventArgs.php
  9. +39 −0 lib/Doctrine/ODM/PHPCR/Events/OnFlushEventArgs.php
  10. +500 −0 lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadata.php
  11. +222 −0 lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadataFactory.php
  12. +229 −0 lib/Doctrine/ODM/PHPCR/Mapping/Driver/AnnotationDriver.php
  13. +73 −0 lib/Doctrine/ODM/PHPCR/Mapping/Driver/DoctrineAnnotations.php
  14. +59 −0 lib/Doctrine/ODM/PHPCR/Mapping/Driver/Driver.php
  15. +96 −0 lib/Doctrine/ODM/PHPCR/Mapping/Driver/DriverChain.php
  16. +45 −0 lib/Doctrine/ODM/PHPCR/Mapping/MappingException.php
  17. +36 −0 lib/Doctrine/ODM/PHPCR/PHPCRException.php
  18. +224 −0 lib/Doctrine/ODM/PHPCR/PersistentCollection.php
  19. +8 −0 lib/Doctrine/ODM/PHPCR/Proxy/Proxy.php
  20. +41 −0 lib/Doctrine/ODM/PHPCR/Proxy/ProxyException.php
  21. +281 −0 lib/Doctrine/ODM/PHPCR/Proxy/ProxyFactory.php
  22. +691 −0 lib/Doctrine/ODM/PHPCR/UnitOfWork.php
  23. +36 −0 tests/Doctrine/Tests/Models/CMS/CmsAddress.php
  24. +33 −0 tests/Doctrine/Tests/Models/CMS/CmsArticle.php
  25. +38 −0 tests/Doctrine/Tests/Models/CMS/CmsGroup.php
  26. +81 −0 tests/Doctrine/Tests/Models/CMS/CmsUser.php
  27. +15 −0 tests/Doctrine/Tests/Models/CMS/CmsUserRights.php
  28. +79 −0 tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php
  29. +117 −0 tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php
  30. +84 −0 tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php
  31. +51 −0 tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php
  32. +143 −0 tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php
  33. +35 −0 tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php
  34. +20 −0 tests/Doctrine/Tests/ODM/PHPCR/ConfigurationTest.php
  35. +34 −0 tests/Doctrine/Tests/ODM/PHPCR/DocumentManagerTest.php
  36. +225 −0 tests/Doctrine/Tests/ODM/PHPCR/Functional/BasicCrudTest.php
  37. +101 −0 tests/Doctrine/Tests/ODM/PHPCR/Functional/CascadePersistTest.php
  38. +34 −0 tests/Doctrine/Tests/ODM/PHPCR/Functional/CollectionTest.php
  39. +36 −0 tests/Doctrine/Tests/ODM/PHPCR/Functional/DocumentRepositoryTest.php
  40. +87 −0 tests/Doctrine/Tests/ODM/PHPCR/Functional/EventManagerTest.php
  41. +2 −0 tests/Doctrine/Tests/ODM/PHPCR/Functional/FlushTest.php
  42. +149 −0 tests/Doctrine/Tests/ODM/PHPCR/Functional/ManyToManyAssociationTest.php
  43. +76 −0 tests/Doctrine/Tests/ODM/PHPCR/Functional/ManyToOneAssociationTest.php
  44. +73 −0 tests/Doctrine/Tests/ODM/PHPCR/Functional/OneToManyAssociationTest.php
  45. +36 −0 tests/Doctrine/Tests/ODM/PHPCR/Functional/OptimisticLockingTest.php
  46. +84 −0 tests/Doctrine/Tests/ODM/PHPCR/Functional/ProxyTest.php
  47. +45 −0 tests/Doctrine/Tests/ODM/PHPCR/Functional/ReferenceTest.php
  48. +1 −0 tests/Doctrine/Tests/ODM/PHPCR/Functional/_files/foo.txt
  49. BIN tests/Doctrine/Tests/ODM/PHPCR/Functional/_files/logo.jpg
  50. +14 −0 tests/Doctrine/Tests/ODM/PHPCR/Functional/_files/user_with_attachment.json
  51. +117 −0 tests/Doctrine/Tests/ODM/PHPCR/Mapping/AbstractMappingDriverTest.php
  52. +71 −0 tests/Doctrine/Tests/ODM/PHPCR/Mapping/AnnotationDriverTest.php
  53. +53 −0 tests/Doctrine/Tests/ODM/PHPCR/Mapping/ClassMetadataFactoryTest.php
  54. +149 −0 tests/Doctrine/Tests/ODM/PHPCR/Mapping/ClassMetadataTest.php
  55. +30 −0 tests/Doctrine/Tests/ODM/PHPCR/PHPCRFunctionalTestCase.php
  56. +8 −0 tests/Doctrine/Tests/ODM/PHPCR/PHPCRTestCase.php
  57. +33 −0 tests/Doctrine/Tests/ODM/PHPCR/Performance/InsertPerformanceTest.php
  58. +99 −0 tests/Doctrine/Tests/ODM/PHPCR/Proxy/ProxyFactoryTest.php
  59. 0 tests/Doctrine/Tests/ODM/PHPCR/Proxy/generated/.empty
  60. +96 −0 tests/Doctrine/Tests/ODM/PHPCR/UnitOfWorkTest.php
  61. +1 −0 tests/Doctrine/Tests/ODM/PHPCR/_files/foo.txt
  62. +23 −0 tests/TestInit.php
  63. +8 −0 tests/phpunit.xml.dist
View
502 LICENSE

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -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)
@@ -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.

0 comments on commit 9cada55

Please sign in to comment.