Change /talks to /presentations
This commit is contained in:
parent
8158c679fd
commit
37603296f0
91 changed files with 168 additions and 166 deletions
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Presentations\TwigExtension;
|
||||
|
||||
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 'modules.presentations';
|
||||
}
|
||||
|
||||
public function getPresentationCount(array $presentations): int
|
||||
{
|
||||
$today = (new \DateTime('today'))->getTimestamp();
|
||||
|
||||
return collect($presentations)
|
||||
->flatMap(fn (ProxySourceItem $presentation) => $presentation->data()->get('events'))
|
||||
->filter(
|
||||
function (array $event) use ($today): bool {
|
||||
assert(array_key_exists(array: $event, key: 'date'));
|
||||
|
||||
return $event['date'] < $today;
|
||||
}
|
||||
)
|
||||
->count();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue