You are here

public function MetatagViewsValuesCleanerTrait::removeEmptyTags in Metatag 8

Removes tags that are empty.

3 calls to MetatagViewsValuesCleanerTrait::removeEmptyTags()
MetatagViewsEditForm::submitForm in metatag_views/src/Form/MetatagViewsEditForm.php
Form submission handler.
MetatagViewsTranslationForm::form in metatag_views/src/Form/MetatagViewsTranslationForm.php
Add the translation form element for meta tags available in the source.
MetatagViewsTranslationForm::submitForm in metatag_views/src/Form/MetatagViewsTranslationForm.php
Form submission handler.

File

metatag_views/src/MetatagViewsValuesCleanerTrait.php, line 32

Class

MetatagViewsValuesCleanerTrait
Collection of helper methods when handling raw tag values.

Namespace

Drupal\metatag_views

Code

public function removeEmptyTags($metatags) {
  $metatags = array_filter($metatags, function ($value) {
    if (is_array($value)) {
      return count(array_filter($value)) > 0;
    }
    else {
      return $value !== '';
    }
  });
  return $metatags;
}