fixed search
This commit is contained in:
parent
3d55e50750
commit
36800804e4
@ -13,18 +13,22 @@ use GuzzleHttp\Client;
|
||||
class SearchController extends AbstractController
|
||||
{
|
||||
|
||||
private static function addFruitToAlbums(array $releases,string $fruit,EntityManagerInterface $entityManager):void{
|
||||
private static function addFruitToAlbums(array $releases, string $fruit, EntityManagerInterface $entityManager): void
|
||||
{
|
||||
foreach ($releases as $release) {
|
||||
$id = $release["id"];
|
||||
$album = $entityManager->getRepository(Album::class)->findBy(
|
||||
['album_id' => $id]
|
||||
);
|
||||
if (!$album) {
|
||||
|
||||
if (count($album) == 0) {
|
||||
$album = new Album();
|
||||
$album->setAlbumId($id);
|
||||
//https://symfony.com/doc/current/doctrine.html#persisting-objects-to-the-database
|
||||
$entityManager->persist($album);
|
||||
$entityManager->flush();
|
||||
} else {
|
||||
$album = $album[0];
|
||||
}
|
||||
$album_fruit = $album->getFruits();
|
||||
if (!str_contains($album_fruit, $fruit)) {
|
||||
@ -36,7 +40,8 @@ class SearchController extends AbstractController
|
||||
}
|
||||
}
|
||||
|
||||
private static function getEmojiName(string $emoji) : string {
|
||||
private static function getEmojiName(string $emoji): string
|
||||
{
|
||||
switch ($emoji) {
|
||||
case "🍎":
|
||||
return "apple";
|
||||
|
@ -9,7 +9,7 @@
|
||||
</style>
|
||||
|
||||
<div class="example-wrapper">
|
||||
<h1>results for {{ query }} with {{fruit_emoji}} ✅</h1>
|
||||
<h1>Results for "{{ query }}" with {{fruit_emoji}}:</h1>
|
||||
{% for result in results %}
|
||||
{% set array = result['title']|split('-') %}
|
||||
{% set artist = array[0] %}
|
||||
|
Loading…
Reference in New Issue
Block a user