mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-10 18:34:32 +02:00
Moved extension to fa-icon logic to a service.
That way we can use it from inside PHP code and the logic is more testable.
This commit is contained in:
parent
bf8455fa42
commit
8b80f31b1e
5 changed files with 170 additions and 31 deletions
|
@ -27,6 +27,7 @@ use App\Entity\PriceInformations\Currency;
|
|||
use App\Services\AmountFormatter;
|
||||
use App\Services\Attachments\AttachmentURLGenerator;
|
||||
use App\Services\EntityURLGenerator;
|
||||
use App\Services\FAIconGenerator;
|
||||
use App\Services\MarkdownParser;
|
||||
use App\Services\MoneyFormatter;
|
||||
use App\Services\SIFormatter;
|
||||
|
@ -47,12 +48,14 @@ class AppExtension extends AbstractExtension
|
|||
protected $siformatter;
|
||||
protected $amountFormatter;
|
||||
protected $attachmentURLGenerator;
|
||||
protected $FAIconGenerator;
|
||||
|
||||
public function __construct(EntityURLGenerator $entityURLGenerator, MarkdownParser $markdownParser,
|
||||
SerializerInterface $serializer, TreeBuilder $treeBuilder,
|
||||
MoneyFormatter $moneyFormatter,
|
||||
SIFormatter $SIFormatter, AmountFormatter $amountFormatter,
|
||||
AttachmentURLGenerator $attachmentURLGenerator)
|
||||
AttachmentURLGenerator $attachmentURLGenerator,
|
||||
FAIconGenerator $FAIconGenerator)
|
||||
{
|
||||
$this->entityURLGenerator = $entityURLGenerator;
|
||||
$this->markdownParser = $markdownParser;
|
||||
|
@ -62,6 +65,7 @@ class AppExtension extends AbstractExtension
|
|||
$this->siformatter = $SIFormatter;
|
||||
$this->amountFormatter = $amountFormatter;
|
||||
$this->attachmentURLGenerator = $attachmentURLGenerator;
|
||||
$this->FAIconGenerator = $FAIconGenerator;
|
||||
}
|
||||
|
||||
public function getFilters()
|
||||
|
@ -90,6 +94,7 @@ class AppExtension extends AbstractExtension
|
|||
return [
|
||||
new TwigFunction('generateTreeData', [$this, 'treeData']),
|
||||
new TwigFunction('attachment_thumbnail', [$this->attachmentURLGenerator, 'getThumbnailURL']),
|
||||
new TwigFunction('ext_to_fa_icon', [$this->FAIconGenerator, 'fileExtensionToFAType']),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue