PHP Класс Salavert\Twig\Extension\TimeAgoExtension

Наследование: extends Twig_Extension
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$translator Symfony\Component\Translation\TranslatorInterface

Открытые методы

Метод Описание
__construct ( Symfony\Component\Translation\TranslatorInterface $translator ) Constructor method
distanceOfTimeInWordsFilter ( string | DateTime $from_time, string | DateTime $to_time = null, boolean $include_seconds = false, boolean $include_months = false ) : string Reports the approximate distance in time between two times given in seconds or in a valid ISO string like.
getFilters ( )
getName ( ) : string Returns the name of the extension.
timeAgoInWordsFilter ( $from_time, boolean $include_seconds = false, boolean $include_months = false ) : mixed Like distance_of_time_in_words, but where to_time is fixed to timestamp()

Приватные методы

Метод Описание
future ( integer $distance_in_minutes, boolean $include_seconds, $distance_in_seconds ) : mixed

Описание методов

__construct() публичный Метод

Constructor method
public __construct ( Symfony\Component\Translation\TranslatorInterface $translator )
$translator Symfony\Component\Translation\TranslatorInterface

distanceOfTimeInWordsFilter() публичный Метод

For example, if the distance is 47 minutes, it'll return "about 1 hour". See the source for the complete wording list. Integers are interpreted as seconds. So, by example to check the distance of time between a created user and their last login: {{ user.createdAt|distance_of_time_in_words(user.lastLoginAt) }} returns "less than a minute". Set include_seconds to true if you want more detailed approximations if distance < 1 minute Set include_months to true if you want approximations in months if days > 30
public distanceOfTimeInWordsFilter ( string | DateTime $from_time, string | DateTime $to_time = null, boolean $include_seconds = false, boolean $include_months = false ) : string
$from_time string | DateTime
$to_time string | DateTime
$include_seconds boolean True to return distance in seconds when it's lower than a minute.
$include_months boolean
Результат string

getFilters() публичный Метод

public getFilters ( )

getName() публичный Метод

Returns the name of the extension.
public getName ( ) : string
Результат string The extension name

timeAgoInWordsFilter() публичный Метод

Like distance_of_time_in_words, but where to_time is fixed to timestamp()
public timeAgoInWordsFilter ( $from_time, boolean $include_seconds = false, boolean $include_months = false ) : mixed
$from_time String or DateTime
$include_seconds boolean
$include_months boolean
Результат mixed

Описание свойств

$translator защищенное свойство

protected TranslatorInterface,Symfony\Component\Translation $translator
Результат Symfony\Component\Translation\TranslatorInterface