Переглянути джерело

[Form] Made FormView implement Countable

Tobias Naumann 14 роки тому
батько
коміт
f6ce451e2c
1 змінених файлів з 10 додано та 1 видалено
  1. 10 1
      src/Symfony/Component/Form/FormView.php

+ 10 - 1
src/Symfony/Component/Form/FormView.php

@@ -14,7 +14,7 @@ namespace Symfony\Component\Form;
 use Symfony\Component\Form\FormInterface;
 use Symfony\Component\Form\Util\ChoiceUtil;
 
-class FormView implements \ArrayAccess, \IteratorAggregate
+class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
 {
     private $vars = array(
         'value' => null,
@@ -179,4 +179,13 @@ class FormView implements \ArrayAccess, \IteratorAggregate
 
         return $choice === $this->vars['value'];
     }
+
+    /**
+     * @see Countable
+     * @return integer
+     */
+    public function count()
+    {
+        return count($this->children);
+    }
 }