adds tags from the ext:news "keywords" field to the index entry

@author Christian Bülter <buelter@kennziffer.com>
@since 26.06.13 14:27
@param string $tags
@param array $newsRecord
@return string
498854
private function addTagsFromNewsKeywords($tags, $newsRecord)
    {
        if (!empty($newsRecord['keywords'])) {
            $keywordsList = GeneralUtility::trimExplode(',', $newsRecord['keywords']);
            foreach ($keywordsList as $keyword) {
                SearchHelper::makeTags($tags, array($keyword));
            }
        }

        return $tags;
    }
1216422
private function buildTagsWhere($tags, $operator, $languageCode)
    {
        $structure = $this->structureManager->getStructure('excerpt');

        $sql2Where = [];
        if ($structure->hasProperty('tags')) {
            $property = new TranslatedProperty(
                $structure->getProperty('tags'),
                $languageCode,
                $this->languageNamespace,
                'excerpt'
            );

            foreach ($tags as $tag) {
                $sql2Where[] = 'page.[' . $property->getName() . '] = ' . $tag;
            }

            if (count($sql2Where) > 0) {
                return '(' . implode(' ' . strtoupper($operator) . ' ', $sql2Where) . ')';
            }
        }

        return '';
    }
713605
private static function formatTags(array $skip, array $tags)
    {
        $chunks = [];

        foreach ($tags as $name => $values) {
            if (\in_array($name, $skip)) {
                continue;
            }

            foreach ($values as $value) {
                $chunks[] = \sprintf('<comment>%s%s</comment> %s', self::inflect($name), empty($value) ? '' : ':', OutputFormatter::escape($value));
            }

            $chunks[] = '';
        }

        return \implode("\n", $chunks);
    }
1156840
public function saveTags($attachment, $tags)
    {
        $newTags = [];
        foreach ($tags as $tag) {
            if (isset($this->config('tags')[$tag])) {
                $newTags[] = $tag;
                if ($this->config('tags')[$tag]['exclusive'] === true) {
                    $this->_clearTag($attachment, $tag);
                }
            }
        }

        $this->Attachments->patchEntity($attachment, ['tags' => $newTags]);
        return (bool)$this->Attachments->save($attachment);
    }
737203
public function scopeWithAnyTags(Builder $query, $tags)
    {
        $tags = static::convertToTags($tags);

        return $query->whereHas('tags', function (Builder $query) use ($tags) {
            $tagIds = $tags->pluck('id')->toArray();

            $query->whereIn('taggables.tag_id', $tagIds);
        });
    }
135513
public function addTag($tagAttributes = array())
	{
		if (is_string($tagAttributes)) {
			$tagAttributes = array('tag' => $tagAttributes);
		}
		$tagAttributes['tag'] = $this->formatTag($tagAttributes['tag']);
		if (!array_key_exists('size', $tagAttributes)) {
			$tagAttributes = array_merge($tagAttributes, array('size' => 1));
		}
		if (!array_key_exists('tag', $tagAttributes)) {
			return false;
		}
		$tag = $tagAttributes['tag'];
		if (empty($this->_tagsArray[$tag])) {
			$this->_tagsArray[$tag] = array();
		}
		if (!empty($this->_tagsArray[$tag]['size']) && !empty($tagAttributes['size'])) {
			$tagAttributes['size'] = ($this->_tagsArray[$tag]['size'] + $tagAttributes['size']);
		} elseif (!empty($this->_tagsArray[$tag]['size'])) {
			$tagAttributes['size'] = $this->_tagsArray[$tag]['size'];
		}
		$this->_tagsArray[$tag] = $tagAttributes;
		//$this->addAttributes($tagAttributes);
		return $this->_tagsArray[$tag];
	}
770985
public function tag($tags)
    {
        $tags = array_slice((array)$tags, 0, 3);
        foreach ($tags as $tag) {
            $this->messageBuilder->addTag($tag);
        }

        return $this;
    }
475303
protected function getFormattedTags(array $tags)
    {
        $add =array();

        foreach ($tags as $key => $value) {
            if (is_bool($value)) {
                $value = $value ? "true" : "false";
            }
            $add[] = "#$key:$value";
        }

        return !empty($add) ? '|'.implode(',', $add) : null;
    }
756274
public function setTags($tags)
    {
        $this->tags = [];
        $this->ref = null;

        if (is_array($tags)) {
            foreach ($tags as $tag) {
                $this->addTag($tag);
            }
        } else {
            $this->addTag($tags);
        }

        return $this;
    }
55731
public function publishedTags($publishedTags = [])
    {
        if (count($publishedTags) <= 0) {
            return $this->publishedTags;
        }

        $this->publishedTags = $publishedTags;
        return $this;
    }
1219097
public static function addCacheTagsByAddressRecords(array $addressRecords)
    {
        $prefix = 'tt_address_';
        $cacheTags = [];
        foreach ($addressRecords as $addressRecord) {
            if (!$addressRecord instanceof Address) {
                continue;
            }
            // cache tag for each addressRecord record
            $cacheTags[] = $prefix . $addressRecord->getUid();

            if ($addressRecord->_getProperty('_localizedUid') != $addressRecord->getUid()) {
                $cacheTags[] = $prefix . $addressRecord->_getProperty('_localizedUid');
            }
        }

        $GLOBALS['TSFE']->addCacheTags($cacheTags);
    }
127279
public function getTagCounts(array $tagTokens): array
    {
        $tagCounts = [];

        foreach ($tagTokens as $tagToken) {
            $tagName = $tagToken['content'];

            if (!array_key_exists($tagName, $tagCounts)) {
                $tagCounts[$tagName] = 0;
            }

            ++$tagCounts[$tagName];
        }

        return $tagCounts;
    }
1192014
public function _processTags(&$tags)
    {
        $tagString = '';
        foreach ($tags as $key => $tag) {
            if ($key != '@text') {
                if (is_array($tag)) {
                    $hasText = FALSE;
                    foreach ($tag as $key => $tagFromGroup) {
                        if ($tagFromGroup->text($this->_doclet) != '') {
                            $hasText = TRUE;
                        }
                    }
                    if ($hasText) {
                        $tagString .= '<dt>'.$tag[0]->displayName().":</dt>\n";
                        foreach ($tag as $tagFromGroup) {
                            $tagString .= '<dd>'.$tagFromGroup->text($this->_doclet)."</dd>\n";
                        }
                    }
                } else {
                    $text = $tag->text($this->_doclet);
                    if ($text != '') {
                        $tagString .= '<dt>'.$tag->displayName().":</dt>\n";
                        $tagString .= '<dd>'.$text."</dd>\n";
                    } elseif ($tag->displayEmpty()) {
                        $tagString .= '<dt>'.$tag->displayName().".</dt>\n";
                    }
                }
            }
        }
        if ($tagString) {
            echo "<dl>\n", $tagString, "</dl>\n";
        }
    }
1021650
public function selectByTags(array $tags)
    {
        $result = [];
        foreach ($this->array['Key2Tags'] as $key => $keyTags) {
            $found = true;
            foreach ($tags as $t) {
                if (array_search($t, $keyTags)===false) {
                    $found = false;
                }
            }

            if ($found) {
                $result[] = $key;
            }
        }

        return $result;
    }
701631
static function tagsToString( array $tags ) {

		$tags = wp_list_sort( $tags, 'tag', 'asc' );

		$str = '';
		foreach ( $tags as $tag ) {
			$str .= $tag['tag'] . ', ';
		}

		return rtrim( $str, ', ' );
	}
781897
public function findEntitiesByTags(array $tags, $locale)
    {
        $products = $this->productRepository->findByTags($tags, $locale);

        return $products;
    }
125518
protected function addIdentifierToTags(string $entryIdentifier, array $tags)
    {
        foreach ($tags as $tag) {
            // Update tag-to-identifier index
            $identifiers = $this->findIdentifiersByTag($tag);
            if (array_search($entryIdentifier, $identifiers) === false) {
                $identifiers[] = $entryIdentifier;
                $this->memcache->set($this->identifierPrefix . 'tag_' . $tag, $identifiers);
            }

            // Update identifier-to-tag index
            $existingTags = $this->findTagsByIdentifier($entryIdentifier);
            if (array_search($tag, $existingTags) === false) {
                $this->memcache->set($this->identifierPrefix . 'ident_' . $entryIdentifier, array_merge($existingTags, $tags));
            }
        }
    }