Przeglądaj źródła

Fixed fatal error with ListMapper::get

Fabien Pennequin 14 lat temu
rodzic
commit
e40f42dc38
1 zmienionych plików z 9 dodań i 1 usunięć
  1. 9 1
      Datagrid/ListCollection.php

+ 9 - 1
Datagrid/ListCollection.php

@@ -32,5 +32,13 @@ class ListCollection
     {
         return array_key_exists($name, $this->elements);
     }
-    
+
+    public function get($name)
+    {
+        if ($this->has($name)) {
+            return $this->elements[$name];
+        }
+
+        throw new \InvalidArgumentException(sprintf('Element "%s" does not exist.', $name));
+    }
 }