Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Bug fixes 2012/10 #9

Merged
merged 7 commits into from

4 participants

@jonmchan

Here's the changes that I had to fix to get it working with the latest dev version of doctrine/common. I also updated the README to reflect code changes and to add clarification on how to use the EntityManager.

README.md
((5 lines not shown))
$cache = new ArrayCache;
- $metadata = new AnnotationDriver(new AnnotationReader);
- $entityManager = new EntityManager($storage, $cache, $metadata);
+ $storage = $storage ?: new DoctrineCacheStorage($cache);
@stof
stof added a note

If you do it this way, you will have an error about reading an undefined variable $storage. What is the goal of adding a ternary operator here ?

@jonmchan
jonmchan added a note

this was simply copied and pasted from the KeyValueStoreTestCase. If there is an issue with it here, the Tests should probably be updated too.

https://github.com/doctrine/KeyValueStore/blob/master/tests/Doctrine/Tests/KeyValueStoreTestCase.php

@Baachi
Baachi added a note

That's not true.
The KeyValueStoreTestCase has a $storage argument, so no warning will be shown.

you are right, erroneous copy and paste. Corrected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
...ctrine/KeyValueStore/Mapping/ClassMetadataFactory.php
@@ -94,5 +94,13 @@ protected function initializeReflection(ClassMetadata $class, ReflectionService
}
}
}
+
+ /**
+ * copied from doctrine/common - tests/Doctrine/Tests/Common/Persistence/Mapping/ClassMetadataFactoryTest.php
+ */
+ protected function isEntity(ClassMetadata $class)
+ {
+ return isset($class->isMappedSuperclass) && $class->isMappedSuperclass === false;
@stof
stof added a note

KeyValueStore does not support mapped superclass. So any mapped class shuld be considered as an entity. This method should simply return true in all cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@beberlei beberlei merged commit f942e51 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
27 README.md
@@ -61,6 +61,8 @@ Suppose we track e-mail campaigns based on campaign id and recipients.
}
}
+### Create
+
$response = new Response("1234", "kontakt@beberlei.de", Response::RECIEVE);
$entityManager->persist($response);
@@ -68,6 +70,18 @@ Suppose we track e-mail campaigns based on campaign id and recipients.
$entityManager->flush();
+### Read
+
+ // untested, i have not tested composite id's
+ $response = $entityManager->find("Response",array("1234","kontakt@beberlei.de"));
+### Update
+ same as create, just reuse the same id.
+
+### Delete
+ $response = $entityManager->find("Response",array("1234","kontakt@beberlei.de"));
+ $entityManager->remove($response);
+ $entityManager->flush();
+
## Configuration
There is no factory yet that simplifies the creation process, here is the
@@ -80,10 +94,17 @@ Cache backend:
use Doctrine\Common\Cache\ArrayCache;
use Doctrine\Common\Annotations\AnnotationReader;
- $storage = new DoctrineCacheStorage($cache);
$cache = new ArrayCache;
- $metadata = new AnnotationDriver(new AnnotationReader);
- $entityManager = new EntityManager($storage, $cache, $metadata);
+ $storage = new DoctrineCacheStorage($cache);
+
+ $reader = new AnnotationReader();
+ $metadata = new AnnotationDriver($reader);
+ $config = new Configuration();
+ $config->setMappingDriverImpl($metadata);
+ $config->setMetadataCache($cache);
+
+ $entityManager = new EntityManager($storage, $config);
+
If you want to use WindowsAzure Table you can use the following configuration
to instantiate the storage:
View
10 lib/Doctrine/KeyValueStore/Mapping/ClassMetadataFactory.php
@@ -48,7 +48,7 @@ protected function getFqcnFromAlias($namespaceAlias, $simpleClassName)
throw new \InvalidArgumentException("aliasing is not supported.");
}
- protected function doLoadMetadata($class, $parent, $rootEntityFound)
+ protected function doLoadMetadata($class, $parent, $rootEntityFound, array $nonSuperclassParents)
{
$this->getDriver()->loadMetadataForClass($class->name, $class);
@@ -94,5 +94,13 @@ protected function initializeReflection(ClassMetadata $class, ReflectionService
}
}
}
+
+ /**
+ * copied from doctrine/common - tests/Doctrine/Tests/Common/Persistence/Mapping/ClassMetadataFactoryTest.php
+ */
+ protected function isEntity(ClassMetadata $class)
+ {
+ return true;
+ }
}
View
2  tests/bootstrap.php
@@ -1,6 +1,6 @@
<?php
-if (!@include __DIR__ . '/../vendor/.composer/autoload.php') {
+if (!@include __DIR__ . '/../vendor/autoload.php') {
die(<<<'EOT'
You must set up the project dependencies, run the following commands:
wget http://getcomposer.org/composer.phar
Something went wrong with that request. Please try again.