Split TalkExtension
into ExperienceExtension
This commit is contained in:
parent
143d1e4f67
commit
90c43e9780
|
@ -12,6 +12,9 @@ sculpin_content_types:
|
|||
permalink: /talks/:basename/
|
||||
|
||||
services:
|
||||
Modules\Experience\TwigExtension\ExperienceTwigExtension:
|
||||
tags:
|
||||
- {name: twig.extension}
|
||||
Modules\Talk\TwigExtension\TalkTwigExtension:
|
||||
tags:
|
||||
- {name: twig.extension}
|
||||
|
|
27
modules/Experience/TwigExtension/ExperienceTwigExtension.php
Normal file
27
modules/Experience/TwigExtension/ExperienceTwigExtension.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Experience\TwigExtension;
|
||||
|
||||
use Sculpin\Contrib\ProxySourceCollection\ProxySourceItem;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFunction;
|
||||
|
||||
class ExperienceTwigExtension extends AbstractExtension
|
||||
{
|
||||
public function getFunctions(): array
|
||||
{
|
||||
return [
|
||||
new TwigFunction('get_years_of_experience', [$this, 'getYearsOfExperience']),
|
||||
];
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return 'modules.experience';
|
||||
}
|
||||
|
||||
public function getYearsOfExperience(): int
|
||||
{
|
||||
return (new \DateTimeImmutable())->format('Y') - 2007;
|
||||
}
|
||||
}
|
|
@ -12,13 +12,12 @@ class TalkTwigExtension extends AbstractExtension
|
|||
{
|
||||
return [
|
||||
new TwigFunction('get_past_talk_count', [$this, 'getPastTalkCount']),
|
||||
new TwigFunction('get_years_of_experience', [$this, 'getYearsOfExperience']),
|
||||
];
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return 'app.opdavies_twig_extension';
|
||||
return 'modules.talk';
|
||||
}
|
||||
|
||||
public function getPastTalkCount(array $talks): int
|
||||
|
@ -36,9 +35,4 @@ class TalkTwigExtension extends AbstractExtension
|
|||
)
|
||||
->count();
|
||||
}
|
||||
|
||||
public function getYearsOfExperience(): int
|
||||
{
|
||||
return (new \DateTimeImmutable())->format('Y') - 2007;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue