Преглед на файлове

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']));
         $method = sprintf('add%s', $this->camelize($mapping['fieldName']));
 
 
         if (!method_exists($object, $method)) {
         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);
         $object->$method($instance);