UserConsentDataPolicyRevision.php in Data Policy 8
File
src/Plugin/views/field/UserConsentDataPolicyRevision.php
View source
<?php
namespace Drupal\data_policy\Plugin\views\field;
use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\views\Plugin\views\field\Date;
use Drupal\views\ResultRow;
use Symfony\Component\DependencyInjection\ContainerInterface;
class UserConsentDataPolicyRevision extends Date {
protected $entityTypeManager;
public function __construct(array $configuration, $plugin_id, $plugin_definition, DateFormatterInterface $date_formatter, EntityStorageInterface $date_format_storage, EntityTypeManagerInterface $entity_type_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $date_formatter, $date_format_storage);
$this->entityTypeManager = $entity_type_manager;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('date.formatter'), $container
->get('entity.manager')
->getStorage('date_format'), $container
->get('entity_type.manager'));
}
public function getValue(ResultRow $values, $field = NULL) {
$value = parent::getValue($values, $field);
if (!empty($value)) {
return $this->entityTypeManager
->getStorage('data_policy')
->loadRevision($value)
->getRevisionCreationTime();
}
}
}