浏览代码

[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);
+    }
 }