浏览代码

Allow to use "addEntity" method, not "addEntities"

Vyacheslav Slinko 12 年之前
父节点
当前提交
dd737ab7e1
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      Admin/AdminHelper.php

+ 5 - 1
Admin/AdminHelper.php

@@ -164,7 +164,11 @@ class AdminHelper
         $method = sprintf('add%s', $this->camelize($mapping['fieldName']));
 
         if (!method_exists($object, $method)) {
-            throw new \RuntimeException(sprintf('Please add a method %s in the %s class!', $method, get_class($object)));
+            $method = rtrim($method, 's');
+
+            if (!method_exists($object, $method)) {
+                throw new \RuntimeException(sprintf('Please add a method %s in the %s class!', $method, get_class($object)));
+            }
         }
 
         $object->$method($instance);