Parcourir la source

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

Vyacheslav Slinko il y a 12 ans
Parent
commit
dd737ab7e1
1 fichiers modifiés avec 5 ajouts et 1 suppressions
  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);