[FEATURE] EXT:form - make FinisherVariableProvider iterable 08/55308/4
authorRalf Zimmermann <ralf.zimmermann@tritum.de>
Tue, 9 Jan 2018 14:52:32 +0000 (15:52 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 14 Jan 2018 13:10:08 +0000 (14:10 +0100)
Makes it possible to iterate through FinisherVariableProvider items.

Resolves: #83396
Releases: master
Change-Id: I0b778b9a6d4ede4d2df8190d6b4821903caee6a4
Reviewed-on: https://review.typo3.org/55308
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/form/Classes/Domain/Finishers/FinisherVariableProvider.php

index 3d248bf..2b7f33d 100644 (file)
@@ -24,7 +24,7 @@ use TYPO3\CMS\Core\Utility\ArrayUtility;
  * **This class is NOT meant to be sub classed by developers.**
  * @internal
  */
-final class FinisherVariableProvider implements \ArrayAccess
+final class FinisherVariableProvider implements \ArrayAccess, \IteratorAggregate, \Countable
 {
 
     /**
@@ -178,4 +178,25 @@ final class FinisherVariableProvider implements \ArrayAccess
     {
         unset($this->objects[$offset]);
     }
+
+    /**
+     * @return \Traversable
+     */
+    public function getIterator(): \Traversable
+    {
+        foreach ($this->objects as $offset => $value) {
+            yield $offset => $value;
+        }
+    }
+
+    /**
+     * Count elements of an object
+     *
+     * @link http://php.net/manual/en/countable.count.php
+     * @return int The custom count as an integer.
+     */
+    public function count()
+    {
+        return count($this->objects);
+    }
 }