2025-05-04 17:48:56 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Presentation\TwigExtension;
|
|
|
|
|
2025-05-04 21:32:34 +01:00
|
|
|
use App\Presentation\Collection\PresentationCollection;
|
2025-05-04 17:48:56 +01:00
|
|
|
use Sculpin\Contrib\ProxySourceCollection\ProxySourceItem;
|
|
|
|
use Twig\Extension\AbstractExtension;
|
|
|
|
use Twig\TwigFunction;
|
|
|
|
|
|
|
|
class PresentationTwigExtension extends AbstractExtension
|
|
|
|
{
|
|
|
|
public function getFunctions(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
new TwigFunction('get_presentation_count', [$this, 'getPresentationCount']),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName(): string
|
|
|
|
{
|
|
|
|
return 'presentations';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPresentationCount(array $presentations): int
|
|
|
|
{
|
2025-05-04 21:32:34 +01:00
|
|
|
$presentationCollection = new PresentationCollection($presentations);
|
2025-05-04 17:48:56 +01:00
|
|
|
|
2025-05-04 21:32:34 +01:00
|
|
|
return $presentationCollection->getPastEvents()->count();
|
2025-05-04 17:48:56 +01:00
|
|
|
}
|
|
|
|
}
|