Display meta-fields in datatables (#1116)

This commit is contained in:
Kevin Papst
2019-09-19 20:28:31 +02:00
committed by GitHub
parent 24cbe3d281
commit 5aa422dde1
71 changed files with 1461 additions and 212 deletions

View File

@@ -80,41 +80,53 @@ class DateExtensions extends AbstractExtension
}
/**
* @param DateTime $date
* @param DateTime|string $date
* @return string
*/
public function dateShort(DateTime $date)
public function dateShort($date)
{
if (null === $this->dateFormat) {
$this->dateFormat = $this->localeSettings->getDateFormat();
}
if (!$date instanceof DateTime) {
$date = new DateTime($date);
}
return date_format($date, $this->dateFormat);
}
/**
* @param DateTime $date
* @param DateTime|string $date
* @return string
*/
public function dateTime(DateTime $date)
public function dateTime($date)
{
if (null === $this->dateTimeFormat) {
$this->dateTimeFormat = $this->localeSettings->getDateTimeFormat();
}
if (!$date instanceof DateTime) {
$date = new DateTime($date);
}
return date_format($date, $this->dateTimeFormat);
}
/**
* @param DateTime $date
* @param DateTime|string $date
* @return string
*/
public function dateTimeFull(DateTime $date)
public function dateTimeFull($date)
{
if (null === $this->dateTimeTypeFormat) {
$this->dateTimeTypeFormat = $this->localeSettings->getDateTimeTypeFormat();
}
if (!$date instanceof DateTime) {
$date = new DateTime($date);
}
$formatter = new \IntlDateFormatter(
$this->localeSettings->getLocale(),
\IntlDateFormatter::MEDIUM,
@@ -128,25 +140,33 @@ class DateExtensions extends AbstractExtension
}
/**
* @param DateTime $date
* @param DateTime|string $date
* @param string $format
* @return false|string
*/
public function dateFormat(DateTime $date, string $format)
public function dateFormat($date, string $format)
{
if (!$date instanceof DateTime) {
$date = new DateTime($date);
}
return date_format($date, $format);
}
/**
* @param DateTime $date
* @param DateTime|string $date
* @return string
*/
public function time(DateTime $date)
public function time($date)
{
if (null === $this->timeFormat) {
$this->timeFormat = $this->localeSettings->getTimeFormat();
}
if (!$date instanceof DateTime) {
$date = new DateTime($date);
}
return date_format($date, $this->timeFormat);
}

View File

@@ -16,6 +16,7 @@ use App\Utils\LocaleSettings;
use NumberFormatter;
use Symfony\Component\Intl\Countries;
use Symfony\Component\Intl\Currencies;
use Symfony\Component\Intl\Languages;
use Symfony\Component\Intl\Locales;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
@@ -67,6 +68,7 @@ class Extensions extends AbstractExtension
new TwigFilter('money', [$this, 'money']),
new TwigFilter('currency', [$this, 'currency']),
new TwigFilter('country', [$this, 'country']),
new TwigFilter('language', [$this, 'language']),
new TwigFilter('docu_link', [$this, 'documentationLink']),
];
}
@@ -162,6 +164,15 @@ class Extensions extends AbstractExtension
return Currencies::getSymbol($currency);
}
/**
* @param string $language
* @return string
*/
public function language($language)
{
return Languages::getName($language, $this->locale);
}
/**
* @param string $country
* @return string