Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function formatDateAttribute(tubepress_api_media_MediaItem $item, $sourceAttributeName, $destinationAttributeName)
 {
     if (!$item->hasAttribute($sourceAttributeName)) {
         return;
     }
     /*
      * Hacky way of warming up the translation service and thus setting locale etc.
      */
     $this->_translator->trans('');
     $dateFormat = $this->_context->get(tubepress_api_options_Names::META_DATEFORMAT);
     $relative = $this->_context->get(tubepress_api_options_Names::META_RELATIVE_DATES);
     $unixTime = $item->getAttribute($sourceAttributeName);
     $formatted = $this->_timeUtils->unixTimeToHumanReadable($unixTime, $dateFormat, $relative);
     $item->setAttribute($destinationAttributeName, $formatted);
 }