File tree Expand file tree Collapse file tree
src/Colibri/Core/ResultSet Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,16 +33,36 @@ abstract class ResultSet extends \IteratorIterator implements \Countable
3333 */
3434 protected $ hydrator ;
3535
36+ /**
37+ * @var string|integer
38+ */
39+ protected $ currentKey ;
40+
3641 /**
3742 * @return mixed
3843 */
3944 public function current ()
4045 {
4146 /** @var EntityInterface $entity */
42- $ entity = $ this ->getReflection ()->newInstance ();
47+ $ reflection = $ this ->getReflection ();
48+ $ entity = $ reflection ->newInstance ();
4349 $ hydrator = $ this ->getHydrator ();
50+ $ metadata = $ this ->getMetadata ();
51+
52+ $ entity = $ hydrator ->hydrate (parent ::current (), $ entity );
4453
45- return $ hydrator ->hydrate (parent ::current (), $ entity );
54+ $ identifier = $ metadata ->getName ($ metadata ->getIdentifier (), Metadata::CAMILIZED );
55+ $ this ->currentKey = $ reflection ->getProperty ($ identifier )->getValue ($ entity );
56+
57+ return $ entity ;
58+ }
59+
60+ /**
61+ * @return string|integer
62+ */
63+ public function key ()
64+ {
65+ return $ this ->currentKey ;
4666 }
4767
4868 /**
@@ -157,4 +177,4 @@ public function count()
157177 return $ this ->getStatementIterator ()->count ();
158178 }
159179
160- }
180+ }
You can’t perform that action at this time.
0 commit comments