Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9f8df8dce3 | |||
| 124f70cf17 | |||
| 75cb3f41e0 | |||
| b1435d39dc |
@@ -50,6 +50,7 @@ class MDTwigExtension extends AbstractExtension {
|
||||
new TwigFilter('cnpj', [$this, 'formatCNPJ']),
|
||||
new TwigFilter('real', [$this, 'formatReal']),
|
||||
new TwigFilter('unicode', [$this, 'returnUnicode']),
|
||||
new TwigFilter('dateshort', [$this, 'formatDateShort']),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -183,4 +184,20 @@ class MDTwigExtension extends AbstractExtension {
|
||||
return $unicode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format and translate date to portuguese.
|
||||
* 2026-04-01 => 01 Apr. 2026
|
||||
*/
|
||||
public function formatDateShort(string $value) : string {
|
||||
|
||||
$df = new \IntlDateFormatter(
|
||||
'pt_BR',
|
||||
\IntlDateFormatter::FULL,
|
||||
\IntlDateFormatter::NONE
|
||||
);
|
||||
|
||||
$df->setPattern('dd-LLL-yy');
|
||||
$d = $df->format(new \DateTime($value));
|
||||
return strtoupper(str_replace(".", "", $d));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,6 +81,7 @@ class TwigRender {
|
||||
try {
|
||||
$this->twig->addExtension(new DebugExtension());
|
||||
$this->twig->addExtension(new MFDESTwigExtension());
|
||||
$this->twig->addExtension(new MDTwigExtension());
|
||||
$this->addPaths();
|
||||
$html = $this->twig->render($this->template, ['data' => $this->data]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user