|
|
|
@ -3,6 +3,7 @@ |
|
|
|
namespace App\Twig\Components; |
|
|
|
namespace App\Twig\Components; |
|
|
|
|
|
|
|
|
|
|
|
use App\Entity\Event; |
|
|
|
use App\Entity\Event; |
|
|
|
|
|
|
|
use App\Enum\KindsEnum; |
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
|
|
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent; |
|
|
|
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent; |
|
|
|
|
|
|
|
|
|
|
|
@ -28,23 +29,38 @@ final class ReadingListList |
|
|
|
$out = []; |
|
|
|
$out = []; |
|
|
|
$seen = []; |
|
|
|
$seen = []; |
|
|
|
foreach ($events as $ev) { |
|
|
|
foreach ($events as $ev) { |
|
|
|
|
|
|
|
$hasArticles = false; |
|
|
|
$tags = $ev->getTags(); |
|
|
|
$tags = $ev->getTags(); |
|
|
|
$isReadingList = false; |
|
|
|
|
|
|
|
$title = null; $slug = null; |
|
|
|
$title = null; $slug = null; |
|
|
|
foreach ($tags as $t) { |
|
|
|
foreach ($tags as $t) { |
|
|
|
if (!is_array($t)) continue; |
|
|
|
if (!is_array($t)) continue; |
|
|
|
if (($t[0] ?? null) === 'type' && ($t[1] ?? null) === 'reading-list') { $isReadingList = true; } |
|
|
|
|
|
|
|
if (($t[0] ?? null) === 'title') { $title = (string)$t[1]; } |
|
|
|
if (($t[0] ?? null) === 'title') { $title = (string)$t[1]; } |
|
|
|
if (($t[0] ?? null) === 'd') { $slug = (string)$t[1]; } |
|
|
|
if (($t[0] ?? null) === 'd') { $slug = (string)$t[1]; } |
|
|
|
} |
|
|
|
} |
|
|
|
if (!$isReadingList) continue; |
|
|
|
|
|
|
|
// Require slug; skip malformed events without slug |
|
|
|
// Require slug; skip malformed events without slug |
|
|
|
if (!$slug) continue; |
|
|
|
if (!$slug) continue; |
|
|
|
|
|
|
|
|
|
|
|
// Collapse newest by slug |
|
|
|
// Collapse the newest by slug |
|
|
|
if (isset($seen[$slug])) continue; |
|
|
|
if (isset($seen[$slug])) continue; |
|
|
|
$seen[$slug] = true; |
|
|
|
$seen[$slug] = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Make sure the 'a' tags contain long form articles |
|
|
|
|
|
|
|
foreach ($tags as $t) { |
|
|
|
|
|
|
|
if (!is_array($t)) continue; |
|
|
|
|
|
|
|
if (($t[0] ?? null) === 'a') { |
|
|
|
|
|
|
|
// Split coordinate by colon and check first part |
|
|
|
|
|
|
|
$coordParts = explode(':', $t[1] ?? '', 3); |
|
|
|
|
|
|
|
if (count($coordParts) < 2) continue; |
|
|
|
|
|
|
|
$kind = (int)$coordParts[0]; |
|
|
|
|
|
|
|
if ($kind == KindsEnum::LONGFORM->value) { |
|
|
|
|
|
|
|
$hasArticles = true; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!$hasArticles) continue; |
|
|
|
|
|
|
|
|
|
|
|
$out[] = [ |
|
|
|
$out[] = [ |
|
|
|
'title' => $title ?: '(untitled)', |
|
|
|
'title' => $title ?: '(untitled)', |
|
|
|
'slug' => $slug, |
|
|
|
'slug' => $slug, |
|
|
|
|