parent
3ea01ec811
commit
f934948559
|
@ -7,7 +7,6 @@ namespace App\TwigExtension;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Twig\Extension\AbstractExtension;
|
use Twig\Extension\AbstractExtension;
|
||||||
use Twig\TwigFunction;
|
use Twig\TwigFunction;
|
||||||
use Webmozart\Assert\Assert;
|
|
||||||
|
|
||||||
final class TalkExtension extends AbstractExtension
|
final class TalkExtension extends AbstractExtension
|
||||||
{
|
{
|
||||||
|
@ -28,16 +27,6 @@ final class TalkExtension extends AbstractExtension
|
||||||
$talkCollection = new Collection($talks);
|
$talkCollection = new Collection($talks);
|
||||||
|
|
||||||
return $talkCollection
|
return $talkCollection
|
||||||
->map(fn($talk): array => (array) $talk['events'])
|
->flatMap(fn($talk): array => (array) $talk['events']);
|
||||||
->filter(function (array $event): bool {
|
|
||||||
try {
|
|
||||||
Assert::keyExists($event, 'title');
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (\RuntimeException $e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ final class TalkExtensionTest extends TestCase
|
||||||
[
|
[
|
||||||
'title' => 'Building static sites with Sculpin',
|
'title' => 'Building static sites with Sculpin',
|
||||||
'events' => [
|
'events' => [
|
||||||
'title' => 'Building static websites with Sculpin',
|
'',
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue