class DateApStyle in AP Style Date 8
Custom twig filter to display dates as AP Style.
Hierarchy
- class \Drupal\date_ap_style\TwigExtension\DateApStyle extends \Twig\Extension\AbstractExtension
Expanded class hierarchy of DateApStyle
1 string reference to 'DateApStyle'
1 service uses DateApStyle
File
- src/
TwigExtension/ DateApStyle.php, line 12
Namespace
Drupal\date_ap_style\TwigExtensionView source
class DateApStyle extends AbstractExtension {
/**
* The date formatter.
*
* @var \Drupal\date_ap_style\ApStyleDateFormatter
*/
protected $apStyleDateFormatter;
/**
* Constructs \Drupal\Core\Template\TwigExtension.
*
* @param \Drupal\date_ap_style\ApStyleDateFormatter $date_formatter
* The date formatter.
*/
public function __construct(ApStyleDateFormatter $date_formatter) {
$this->apStyleDateFormatter = $date_formatter;
}
/**
* Generates a list of all Twig filters that this extension defines.
*
* @return array
* A key/value array that defines custom Twig filters. The key denotes the
* filter name used in the tag, e.g.:
* @code
* {{ foo|testfilter }}
* @endcode
*
* The value is a standard PHP callback that defines what the filter does.
*/
public function getFilters() {
return [
new TwigFilter('ap_style', [
$this->apStyleDateFormatter,
'formatTimestamp',
]),
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DateApStyle:: |
protected | property | The date formatter. | |
DateApStyle:: |
public | function | Generates a list of all Twig filters that this extension defines. | |
DateApStyle:: |
public | function | Constructs \Drupal\Core\Template\TwigExtension. |