You are here

public function FaqFieldItem::isEmpty in FAQ Field 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/Field/FieldType/FaqFieldItem.php \Drupal\faqfield\Plugin\Field\FieldType\FaqFieldItem::isEmpty()

Determines whether the data structure is empty.

Return value

bool TRUE if the data structure is empty, FALSE otherwise.

Overrides Map::isEmpty

File

src/Plugin/Field/FieldType/FaqFieldItem.php, line 103

Class

FaqFieldItem
Plugin implementation of the 'faqfield' field type.

Namespace

Drupal\faqfield\Plugin\Field\FieldType

Code

public function isEmpty() {
  $answer = $this
    ->get('answer')
    ->getValue();
  $question = $this
    ->get('question')
    ->getValue();
  $answer_value = is_array($answer) ? $answer['value'] : $answer;

  // Return TRUE only if both are empty.
  return empty($question) && empty($answer_value);
}