Skip to content
This repository has been archived by the owner on Oct 1, 2021. It is now read-only.

Commit

Permalink
getEntitiesToIndex() now returns an iterable
Browse files Browse the repository at this point in the history
  • Loading branch information
jmsche committed Jan 14, 2020
1 parent 0256e4b commit 54b2125
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Indexer/IndexerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ public function getMappings(): array;
public function getIndexAction($entity, Type $type): string;

/**
* Return an array of all the entities that need to be reindexed
* Return an iterable of all the entities that need to be reindexed
* during a rebuild operation.
*
* @abstract
*/
public function getEntitiesToIndex(EntityManager $em, Type $type): array;
public function getEntitiesToIndex(EntityManager $em, Type $type): iterable;

/**
* Get the entities to index provided a given entity
Expand Down
3 changes: 1 addition & 2 deletions src/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ public function rebuildType($typeName)
$mapping->send();

// Reindex data
$entities = $indexer->getEntitiesToIndex($this->container->get('doctrine.orm.entity_manager'), $type);
foreach ($entities as $entity) {
foreach ($indexer->getEntitiesToIndex($this->container->get('doctrine.orm.entity_manager'), $type) as $entity) {
$indexer->addIndex($entity, $type);
}
$this->container->get('doctrine.orm.entity_manager')->clear();
Expand Down
2 changes: 1 addition & 1 deletion tests/Listener/Mock/FooIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function getIndexAction($entity, Type $type): string
return '';
}

public function getEntitiesToIndex(EntityManager $em, Type $type): array
public function getEntitiesToIndex(EntityManager $em, Type $type): iterable
{
return [];
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Mock/BarIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function getIndexAction($entity, Type $type): string
return '';
}

public function getEntitiesToIndex(EntityManager $em, Type $type): array
public function getEntitiesToIndex(EntityManager $em, Type $type): iterable
{
return [];
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Mock/FooIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function getIndexAction($entity, Type $type): string
return '';
}

public function getEntitiesToIndex(EntityManager $em, Type $type): array
public function getEntitiesToIndex(EntityManager $em, Type $type): iterable
{
return [];
}
Expand Down

0 comments on commit 54b2125

Please sign in to comment.