Same filename and directory in other branches
- 8.9.x core/lib/Drupal/Core/Datetime/FormattedDateDiff.php
- 9 core/lib/Drupal/Core/Datetime/FormattedDateDiff.php
Namespace
Drupal\Core\Datetime
File
core/lib/Drupal/Core/Datetime/FormattedDateDiff.php
View source
<?php
namespace Drupal\Core\Datetime;
use Drupal\Core\Cache\CacheableDependencyInterface;
use Drupal\Core\Cache\UnchangingCacheableDependencyTrait;
use Drupal\Core\Render\RenderableInterface;
class FormattedDateDiff implements RenderableInterface, CacheableDependencyInterface {
use UnchangingCacheableDependencyTrait;
protected $string;
protected $maxAge;
public function __construct($string, $max_age) {
$this->string = $string;
$this->maxAge = $max_age;
}
public function getString() {
return $this->string;
}
public function getCacheMaxAge() {
return $this->maxAge;
}
public function toRenderable() {
return [
'#markup' => $this->string,
'#cache' => [
'max-age' => $this->maxAge,
],
];
}
}
Classes