瀏覽代碼

Fix multiple IDs

Michel Weimerskirch 14 年之前
父節點
當前提交
bb1fdaf1dd
共有 1 個文件被更改,包括 9 次插入1 次删除
  1. 9 1
      Model/ORM/ModelManager.php

+ 9 - 1
Model/ORM/ModelManager.php

@@ -98,9 +98,17 @@ class ModelManager implements ModelManagerInterface
         $this->entityManager->flush();
     }
 
+    /**
+     * Find one object from the given class repository.
+     * 
+     * @param string $class Class name
+     * @param string|int $id Identifier. Can be a string with several IDs concatenated, separated by '-'.
+     * @return Object 
+     */
     public function findOne($class, $id)
     {
-        return $this->entityManager->getRepository($class)->find($id);
+        $values = array_combine($this->getIdentifierFieldNames($class), explode('-', $id));
+        return $this->entityManager->getRepository($class)->find($values);
     }
 
     public function find($class, array $criteria = array())