Skip to content

Commit

Permalink
fix: restore transformer
Browse files Browse the repository at this point in the history
  • Loading branch information
vinceAmstoutz committed Nov 12, 2023
1 parent 8a001e9 commit b52b8c3
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions sources/AppBundle/Indexation/Meetups/Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use AlgoliaSearch\Client;
use AppBundle\Event\Model\Meetup;
use AppBundle\Event\Model\Repository\MeetupRepository;
use AppBundle\Offices\OfficesCollection;
use CCMBenchmark\Ting\Repository\CollectionInterface;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;
Expand All @@ -21,10 +22,22 @@ class Runner
*/
protected $meetupRepository;

/**
* @var OfficesCollection
*/
protected $officiesCollection;

/**
* @var Transformer
*/
protected $transformer;

public function __construct(Client $algoliaClient, MeetupRepository $meetupRepository)
{
$this->algoliaClient = $algoliaClient;
$this->meetupRepository = $meetupRepository;
$this->officiesCollection = new OfficesCollection();
$this->transformer = new Transformer($this->officiesCollection);
}

/**
Expand Down Expand Up @@ -80,18 +93,21 @@ private function getMeetupsFromDatabase()
{
$meetupsCollection = $this->meetupRepository->getAll();

return $this->fromCollectionInterfaceToArray($meetupsCollection);
return $this->transformMeetupsForIndexation($meetupsCollection);
}

/**
* @param CollectionInterface $meetupsCollection
* @return array<Meetup>
*/
public function fromCollectionInterfaceToArray($meetupsCollection)
public function transformMeetupsForIndexation($meetupsCollection)
{
$meetupsArray = [];
foreach ($meetupsCollection as $meetup) {
$meetupsArray[] = $meetup;
if (null === ($transformedMeetup = $this->transformer->transform($meetup))) {
continue;
}
$meetupsArray[] = $transformedMeetup;
}
return $meetupsArray;
}
Expand Down

0 comments on commit b52b8c3

Please sign in to comment.