3 namespace Drupal\metatag_views;
6 * Collection of helper methods when handling raw tag values.
8 trait MetatagViewsValuesCleanerTrait {
11 * Clears the metatag form state values from illegal elements.
13 * @param array $metatags
14 * Array of values to submit.
17 * Filtered metatag array.
19 public function clearMetatagViewsDisallowedValues(array $metatags) {
20 // Get all legal tags.
21 $tags = $this->metatagManager->sortedTags();
23 // Return only common elements.
24 $metatags = array_intersect_key($metatags, $tags);
30 * Removes tags that are empty.
32 public function removeEmptyTags($metatags) {
33 $metatags = array_filter($metatags, function ($value) {
34 if (is_array($value)) {
35 return count(array_filter($value)) > 0;