/** * @return Genre[] */ public function getAllNonEmptyGenres() : array { $qb = $this->entityManager->createQueryBuilder(); $qb2 = $this->entityManager->createQueryBuilder(); $qb2->select('IDENTITY(song.genre)')->from(Song::getClassName(), 'song')->distinct(); $qb->select('genre')->from(Genre::getClassName(), 'genre')->where('genre.id IN (' . $qb2->getDQL() . ')'); return $qb->getQuery()->getResult(); }
public function processSong(Song $song) { //format name $name = $song->getName(); //remove starting dot if (Strings::startsWith($name, '.')) { $name = Strings::substring($name, 1); } if (Strings::startsWith($name, ' ')) { $name = Strings::substring($name, 1); } //change underscore to space if (Strings::contains($name, '_-_')) { $name = Strings::replace($name, '~_-_~', '-'); } $name = Strings::replace($name, '~_~', ' '); //end of format name $song->setName($name); //load metadata from name if (!$song->hasMetadata()) { $this->addSongMetadata($song); } }