--- a/Entity/DocumentRepository.php Mon Oct 17 17:17:14 2011 +0200
+++ b/Entity/DocumentRepository.php Tue Oct 18 10:32:30 2011 +0200
@@ -13,16 +13,20 @@
*/
class DocumentRepository extends EntityRepository
{
+ function findOneByExternalId($external_id)
+ {
+ return $this->findOneBy(array("externalId" => strval($external_id)));
+ }
function writeDocument(DocumentInterface $document)
{
# get document from id
- $baseDocument = $this->findOneBy(array("externalId" => $document->getId()));
+ $baseDocument = $this->findOneByExternalId($document->getId());
if(is_null($baseDocument))
{
$baseDocument = new Document();
- $baseDocument->setExternalId($document->getId());
+ $baseDocument->setExternalId(strval($document->getId()));
}
$baseDocument->setDescription($document->getDescription());
$baseDocument->setTitle($document->getTitle());
@@ -35,8 +39,9 @@
function removeDocument(DocumentInterface $document)
{
- $baseDocument = $this->findOneBy(array("externalId" => $document->getId()));
- if(!is_null($baseDocument)) {
+ $baseDocument = $this->findOneByExternalId($document->getId());
+ if(!is_null($baseDocument))
+ {
$this->getEntityManager()->remove($baseDocument);
}
}