findAssoc() public method

Fetches all records and returns an associative array indexed by key
public findAssoc ( array $criteria, string $key = NULL ) : array
$criteria array
$key string
return array
 public function hashSongs()
 {
     /** @var Song[] $songs */
     $songs = $this->songRepository->findAssoc([]);
     /** @var \SplFileInfo $song */
     foreach (Finder::findFiles('*')->from($this->songsDirectory) as $song) {
         $songHash = md5_file($song->getRealPath());
         $songEntity = $songs[$song->getBasename('.mp3')];
         $songEntity->setHash($songHash);
     }
     $this->entityManager->flush();
 }