Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c9f406
commit 213e430
Showing
3 changed files
with
73 additions
and
73 deletions.
There are no files selected for viewing
50 changes: 25 additions & 25 deletions
50
phpmyfaq/src/phpMyFAQ/Template/FormatDateTwigExtension.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
<?php | ||
|
||
namespace phpMyFAQ\Template; | ||
|
||
use phpMyFAQ\Configuration; | ||
use phpMyFAQ\Date; | ||
use Twig\Extension\AbstractExtension; | ||
use Twig\TwigFilter; | ||
|
||
class FormatDateTwigExtension extends AbstractExtension | ||
{ | ||
public function getFilters(): array | ||
{ | ||
return [ | ||
new TwigFilter('formatDate', $this->formatDate(...)), | ||
]; | ||
} | ||
|
||
private function formatDate(string $string): string | ||
{ | ||
$faqConfig = Configuration::getConfigurationInstance(); | ||
$date = new Date($faqConfig); | ||
return $date->format($string); | ||
} | ||
} | ||
<?php | ||
|
||
namespace phpMyFAQ\Template; | ||
|
||
use phpMyFAQ\Configuration; | ||
use phpMyFAQ\Date; | ||
use Twig\Extension\AbstractExtension; | ||
use Twig\TwigFilter; | ||
|
||
class FormatDateTwigExtension extends AbstractExtension | ||
{ | ||
public function getFilters(): array | ||
{ | ||
return [ | ||
new TwigFilter('formatDate', $this->formatDate(...)), | ||
]; | ||
} | ||
|
||
private function formatDate(string $string): string | ||
{ | ||
$faqConfig = Configuration::getConfigurationInstance(); | ||
$date = new Date($faqConfig); | ||
return $date->format($string); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
<?php | ||
|
||
namespace phpMyFAQ\Template; | ||
|
||
use phpMyFAQ\Date; | ||
use Twig\Extension\AbstractExtension; | ||
use Twig\TwigFilter; | ||
|
||
class IsoDateTwigExtension extends AbstractExtension | ||
{ | ||
public function getFilters(): array | ||
{ | ||
return [ | ||
new TwigFilter('createIsoDate', $this->createIsoDate(...)), | ||
]; | ||
} | ||
|
||
private function createIsoDate(string $string): string | ||
{ | ||
return Date::createIsoDate($string); | ||
} | ||
} | ||
<?php | ||
|
||
namespace phpMyFAQ\Template; | ||
|
||
use phpMyFAQ\Date; | ||
use Twig\Extension\AbstractExtension; | ||
use Twig\TwigFilter; | ||
|
||
class IsoDateTwigExtension extends AbstractExtension | ||
{ | ||
public function getFilters(): array | ||
{ | ||
return [ | ||
new TwigFilter('createIsoDate', $this->createIsoDate(...)), | ||
]; | ||
} | ||
|
||
private function createIsoDate(string $string): string | ||
{ | ||
return Date::createIsoDate($string); | ||
} | ||
} |
52 changes: 26 additions & 26 deletions
52
phpmyfaq/src/phpMyFAQ/Template/PermissionTranslationTwigExtension.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
<?php | ||
|
||
namespace phpMyFAQ\Template; | ||
|
||
use phpMyFAQ\Translation; | ||
use Twig\Extension\AbstractExtension; | ||
use Twig\TwigFilter; | ||
|
||
class PermissionTranslationTwigExtension extends AbstractExtension | ||
{ | ||
public function getFilters(): array | ||
{ | ||
return [ | ||
new TwigFilter('permission', $this->getPermissionTranslation(...)), | ||
]; | ||
} | ||
|
||
private function getPermissionTranslation(string $string): string | ||
{ | ||
$translationCode = sprintf( | ||
'permission::%s', | ||
$string | ||
); | ||
return Translation::get($translationCode); | ||
} | ||
} | ||
<?php | ||
|
||
namespace phpMyFAQ\Template; | ||
|
||
use phpMyFAQ\Translation; | ||
use Twig\Extension\AbstractExtension; | ||
use Twig\TwigFilter; | ||
|
||
class PermissionTranslationTwigExtension extends AbstractExtension | ||
{ | ||
public function getFilters(): array | ||
{ | ||
return [ | ||
new TwigFilter('permission', $this->getPermissionTranslation(...)), | ||
]; | ||
} | ||
|
||
private function getPermissionTranslation(string $string): string | ||
{ | ||
$translationCode = sprintf( | ||
'permission::%s', | ||
$string | ||
); | ||
return Translation::get($translationCode); | ||
} | ||
} |