1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Obblm\Core\Twig; |
4
|
|
|
|
5
|
|
|
use Obblm\Core\Entity\Rule; |
6
|
|
|
use Obblm\Core\Entity\Team; |
7
|
|
|
use Obblm\Core\Helper\ImageHelper; |
8
|
|
|
use Twig\Extension\AbstractExtension; |
9
|
|
|
use Twig\TwigFunction; |
10
|
|
|
|
11
|
|
|
class AssetsExtension extends AbstractExtension |
12
|
|
|
{ |
13
|
|
|
protected $imageHelper; |
14
|
|
|
|
15
|
|
|
public function __construct(ImageHelper $imageHelper) |
16
|
|
|
{ |
17
|
|
|
$this->imageHelper = $imageHelper; |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
public function getFunctions() |
21
|
|
|
{ |
22
|
|
|
return [ |
23
|
|
|
new TwigFunction('roster_image', [$this, 'getRosterImageUrl']), |
24
|
|
|
new TwigFunction('team_logo', [$this, 'getTeamLogo']), |
25
|
|
|
new TwigFunction('team_cover', [$this, 'getTeamCover']), |
26
|
|
|
]; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function getRosterImageUrl(Rule $rule, string $roster, int $width = null, int $height = 150) |
30
|
|
|
{ |
31
|
|
|
return $this->imageHelper->getRosterImage($rule, $roster, $width, $height); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function getTeamLogo(Team $team, int $width = 200, int $height = null) |
35
|
|
|
{ |
36
|
|
|
return $this->imageHelper->getTeamLogo($team, $width, $height); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function getTeamCover(Team $team, int $width = null, int $height = null) |
40
|
|
|
{ |
41
|
|
|
return $this->imageHelper->getTeamCover($team, $width, $height); |
42
|
|
|
} |
43
|
|
|
} |
44
|
|
|
|