Skip to content

Commit

Permalink
patch repository
Browse files Browse the repository at this point in the history
  • Loading branch information
oosor committed Jul 16, 2020
1 parent a08f5a6 commit 4043ea2
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lib/Repositories/SharedModulesRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,37 @@

namespace Hedera\Repositories;

use Doctrine\Common\Collections\Collection;
use GraphAware\Neo4j\OGM\Repository\BaseRepository;
use GraphAware\Neo4j\OGM\Common\Collection as HederaCollection;

class SharedModulesRepository extends BaseRepository
{
/**
* @param Collection $collection
* @param string $classConfig
* @return Collection<array>
* @throws \Exception
*/
public function loadConfigs(Collection $collection, string $classConfig)
{
if ($collection->isEmpty()) {
return new HederaCollection();
}

$ids = $collection->map(function ($item) {
return $item->getId();
});

$query = $this->entityManager
->createQuery('MATCH (n:' . $this->getClassName() . ') WHERE ID(n) IN $id MATCH (n)<-[:MODULE_CONFIG_IN]-(conf) RETURN n, conf');
$query->setParameter('id', $ids);
$query
->addEntityMapping('n', $this->getClassName())
->addEntityMapping('conf', $classConfig);

$result = $query->execute();

return new HederaCollection($result);
}
}

0 comments on commit 4043ea2

Please sign in to comment.