Browse Source

Added the ability to count registry objects.

Robert Pustulka 9 years ago
parent
commit
29af1bcba4
1 changed files with 12 additions and 1 deletions
  1. 12 1
      src/Core/ObjectRegistry.php

+ 12 - 1
src/Core/ObjectRegistry.php

@@ -17,6 +17,7 @@ namespace Cake\Core;
 use ArrayIterator;
 use Cake\Event\EventDispatcherInterface;
 use Cake\Event\EventListenerInterface;
+use Countable;
 use IteratorAggregate;
 use RuntimeException;
 
@@ -36,7 +37,7 @@ use RuntimeException;
  * @see \Cake\View\HelperRegistry
  * @see \Cake\Console\TaskRegistry
  */
-abstract class ObjectRegistry implements IteratorAggregate
+abstract class ObjectRegistry implements Countable, IteratorAggregate
 {
 
     /**
@@ -359,6 +360,16 @@ abstract class ObjectRegistry implements IteratorAggregate
     }
 
     /**
+     * Returns the number of loaded objects.
+     *
+     * @return int
+     */
+    public function count()
+    {
+        return count($this->_loaded);
+    }
+
+    /**
      * Debug friendly object properties.
      *
      * @return array