Backend\Core\Engine\Language::getLabel PHP Method

getLabel() public static method

Get a label from the language-file
Deprecation:
public static getLabel ( string $key, string $module = null ) : string
$key string The key to get.
$module string The module wherein we should search.
return string
    public static function getLabel($key, $module = null)
    {
        trigger_error('Backend\\Core\\Engine\\Language is deprecated.
             It has been moved to Backend\\Core\\Language\\Language', E_USER_DEPRECATED);
        return parent::getLabel($key, $module);
    }

Usage Example

Example #1
0
 /**
  * Calculate time ago.
  *
  * @param int $timestamp Unix timestamp from the past.
  * @return string
  */
 public static function calculateTimeAgo($timestamp)
 {
     $secondsBetween = time() - $timestamp;
     // calculate
     $hours = floor($secondsBetween / (60 * 60));
     $minutes = floor($secondsBetween / 60);
     $seconds = floor($secondsBetween);
     // today start
     $todayStart = (int) strtotime(date('d F Y'));
     // today
     if ($timestamp >= $todayStart) {
         // today
         if ($hours >= 1) {
             return BL::getLabel('Today') . ' ' . date('H:i', $timestamp);
         } elseif ($minutes > 1) {
             // more than one minute
             return sprintf(BL::getLabel('MinutesAgo'), $minutes);
         } elseif ($minutes == 1) {
             // one minute
             return BL::getLabel('OneMinuteAgo');
         } elseif ($seconds > 1) {
             // more than one second
             return sprintf(BL::getLabel('SecondsAgo'), $seconds);
         } elseif ($seconds <= 1) {
             // one second
             return BL::getLabel('OneSecondAgo');
         }
     } elseif ($timestamp < $todayStart && $timestamp >= $todayStart - 86400) {
         // yesterday
         return BL::getLabel('Yesterday') . ' ' . date('H:i', $timestamp);
     } else {
         // older
         return date('d/m/Y H:i', $timestamp);
     }
 }
All Usage Examples Of Backend\Core\Engine\Language::getLabel