EntityFieldNullCompareType.php in Entity Field Condition 2.0.x
File
src/Plugin/EntityFieldCondition/CompareType/EntityFieldNullCompareType.php
View source
<?php
declare (strict_types=1);
namespace Drupal\entity_field_condition\Plugin\EntityFieldCondition\CompareType;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\entity_field_condition\Annotation\EntityFieldCompareType;
class EntityFieldNullCompareType extends EntityFieldCompareTypePluginBase {
public function evaluate(ContentEntityInterface $entity, string $field_name) : bool {
if (!$entity
->hasField($field_name)) {
return FALSE;
}
return $entity
->get($field_name)->value === NULL;
}
}