Split TalkExtension
into ExperienceExtension
This commit is contained in:
parent
143d1e4f67
commit
90c43e9780
|
@ -12,6 +12,9 @@ sculpin_content_types:
|
||||||
permalink: /talks/:basename/
|
permalink: /talks/:basename/
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
Modules\Experience\TwigExtension\ExperienceTwigExtension:
|
||||||
|
tags:
|
||||||
|
- {name: twig.extension}
|
||||||
Modules\Talk\TwigExtension\TalkTwigExtension:
|
Modules\Talk\TwigExtension\TalkTwigExtension:
|
||||||
tags:
|
tags:
|
||||||
- {name: twig.extension}
|
- {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 [
|
return [
|
||||||
new TwigFunction('get_past_talk_count', [$this, 'getPastTalkCount']),
|
new TwigFunction('get_past_talk_count', [$this, 'getPastTalkCount']),
|
||||||
new TwigFunction('get_years_of_experience', [$this, 'getYearsOfExperience']),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(): string
|
public function getName(): string
|
||||||
{
|
{
|
||||||
return 'app.opdavies_twig_extension';
|
return 'modules.talk';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPastTalkCount(array $talks): int
|
public function getPastTalkCount(array $talks): int
|
||||||
|
@ -36,9 +35,4 @@ class TalkTwigExtension extends AbstractExtension
|
||||||
)
|
)
|
||||||
->count();
|
->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getYearsOfExperience(): int
|
|
||||||
{
|
|
||||||
return (new \DateTimeImmutable())->format('Y') - 2007;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue