Skip to content

Commit 570441d

Browse files
authored
Update ResultSet.php
1 parent 83832b5 commit 570441d

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

src/Colibri/Core/ResultSet/ResultSet.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff 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+
}

0 commit comments

Comments
 (0)