Compare commits

..

8 Commits

3 changed files with 25 additions and 1 deletions
+17
View File
@@ -50,6 +50,7 @@ class MDTwigExtension extends AbstractExtension {
new TwigFilter('cnpj', [$this, 'formatCNPJ']), new TwigFilter('cnpj', [$this, 'formatCNPJ']),
new TwigFilter('real', [$this, 'formatReal']), new TwigFilter('real', [$this, 'formatReal']),
new TwigFilter('unicode', [$this, 'returnUnicode']), new TwigFilter('unicode', [$this, 'returnUnicode']),
new TwigFilter('dateshort', [$this, 'formatDateShort']),
]; ];
} }
@@ -183,4 +184,20 @@ class MDTwigExtension extends AbstractExtension {
return $unicode; 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));
}
} }
+6
View File
@@ -113,4 +113,10 @@ class Request {
} }
} }
/**
* Change or set the value of a parameter.
*/
public function setQueryParameter(string $key, string $value = "") {
$this->post[$key] = $value;
}
} }
+2 -1
View File
@@ -63,7 +63,7 @@ class TwigRender {
/** /**
* Add global variable(s) to template. * Add global variable(s) to template.
* *
* @return string * @return object
*/ */
public function addGlobals($name, $value) : self { public function addGlobals($name, $value) : self {
$this->twig->addGlobal($name, $value); $this->twig->addGlobal($name, $value);
@@ -81,6 +81,7 @@ class TwigRender {
try { try {
$this->twig->addExtension(new DebugExtension()); $this->twig->addExtension(new DebugExtension());
$this->twig->addExtension(new MFDESTwigExtension()); $this->twig->addExtension(new MFDESTwigExtension());
$this->twig->addExtension(new MDTwigExtension());
$this->addPaths(); $this->addPaths();
$html = $this->twig->render($this->template, ['data' => $this->data]); $html = $this->twig->render($this->template, ['data' => $this->data]);
} }