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