damax-solutions /
media
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Damax\Media\Bridge\Twig; |
||
| 6 | |||
| 7 | use Damax\Media\Domain\FileFormatter; |
||
| 8 | use Damax\Media\Domain\Image\UrlBuilder; |
||
| 9 | use Damax\Media\Domain\Model\MediaId; |
||
| 10 | use Twig\TwigFilter; |
||
| 11 | use Twig\TwigFunction; |
||
| 12 | use Twig_Extension; |
||
| 13 | |||
| 14 | final class MediaExtension extends Twig_Extension |
||
| 15 | { |
||
| 16 | private $fileFormatter; |
||
| 17 | private $urlBuilder; |
||
| 18 | |||
| 19 | public function __construct(FileFormatter $fileFormatter, UrlBuilder $urlBuilder = null) |
||
| 20 | { |
||
| 21 | $this->fileFormatter = $fileFormatter; |
||
| 22 | $this->urlBuilder = $urlBuilder; |
||
| 23 | } |
||
| 24 | |||
| 25 | public function getFunctions(): array |
||
| 26 | { |
||
| 27 | return [ |
||
| 28 | new TwigFunction('media_image_url', [$this, 'buildImageUrl']), |
||
| 29 | ]; |
||
| 30 | } |
||
| 31 | |||
| 32 | public function getFilters(): array |
||
| 33 | { |
||
| 34 | return [ |
||
| 35 | new TwigFilter('media_file_size', [$this->fileFormatter, 'formatSize']), |
||
| 36 | ]; |
||
| 37 | } |
||
| 38 | |||
| 39 | public function buildImageUrl(string $imageId, array $params = []): string |
||
| 40 | { |
||
| 41 | $mediaId = MediaId::fromString($imageId); |
||
| 42 | |||
| 43 | return $this->urlBuilder->build($mediaId, $params); |
||
|
0 ignored issues
–
show
|
|||
| 44 | } |
||
| 45 | } |
||
| 46 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.