UserConsentState.php in Data Policy 8
File
src/Plugin/views/field/UserConsentState.php
View source
<?php
namespace Drupal\data_policy\Plugin\views\field;
use Drupal\data_policy\Entity\UserConsentInterface;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;
class UserConsentState extends FieldPluginBase {
public function render(ResultRow $values) {
$states = [
UserConsentInterface::STATE_AGREE => $this
->t('Agree'),
UserConsentInterface::STATE_NOT_AGREE => $this
->t('Not agree'),
UserConsentInterface::STATE_UNDECIDED => $this
->t('Undecided'),
];
$value = $this
->getValue($values);
return $this
->sanitizeValue($states[$value]);
}
}