Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| feb0308d68 | |||
| f2e2f1244a | |||
| 8d2e197ffa | |||
| 9f8df8dce3 | |||
| 124f70cf17 | |||
| 75cb3f41e0 | |||
| b1435d39dc | |||
| 16270fedf8 |
@@ -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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
@@ -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]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user