]> git.andy128k.dev Git - ipf.git/commitdiff
fix GetObjectOr404 shortcut
authorAndrey Kutejko <andy128k@gmail.com>
Fri, 28 Oct 2011 17:07:19 +0000 (20:07 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Fri, 28 Oct 2011 17:07:19 +0000 (20:07 +0300)
ipf/shortcuts.php

index a5236dcab32796da8bf69c553b143625f462c452..2e4415d540954543390a320032e1b9ba24155201 100644 (file)
@@ -4,10 +4,9 @@ final class IPF_Shortcuts{
 
     static function GetObjectOr404($object, $id)
     {
-        $item = new $object($id);
-        if ((int)$id > 0 && $item->id == $id) {
-            return $item;
-        }
+        $obj = IPF_ORM::getTable($object)->findOneById($id);
+        if ($obj)
+            return $obj;
         throw new IPF_HTTP_Error404();
     }
 
@@ -30,4 +29,4 @@ final class IPF_Shortcuts{
         $extra['model'] = $model;
         return new IPF_Form_Model($data, $extra, $label_suffix);
     }
-}
\ No newline at end of file
+}