Checks if a tag already exists and returns the id if yes.

@param string $tag Tag key.
@return null|int
356427
protected function _tagExists($tag) {
		$tagsTable = $this->_table->{$this->getConfig('tagsAlias')}->getTarget();
		$result = $tagsTable->find()
			->where([
				$tagsTable->aliasField('slug') => $tag,
			])
			->select([
				$tagsTable->aliasField($tagsTable->getPrimaryKey())
			])
			->first();
		if (!empty($result)) {
			return $result->id;
		}
		return null;
	}
876891
public function isVoidElement($tag = null)
    {
        if (null === $tag) {
            $tag = $this->getTag();
        }

        return in_array($tag, $this->voidElements);
    }
919095
public function checkIfTagMatchesRecords($tag)
    {
        // if tag list is empty, fetch them from the result list
        // otherwise use the cached result list
        if (!$this->tagsInSearchResult) {
            $this->tagsInSearchResult = $this->pObj->tagsInSearchResult = $this->db->getTagsFromSearchResult();
            $GLOBALS['TSFE']->fe_user->setKey('ses', 'ke_search.tagsInSearchResults', $this->tagsInSearchResult);
        }

        return array_key_exists($tag, $this->tagsInSearchResult);
    }
786548
public function hasSingleTagInsideElement($tag)
    {
        // There should be exactly 1 element child with given tag
        if (count($children = $this->getChildren(true)) !== 1 || $children[0]->nodeName !== $tag) {
            return false;
        }

        // And there should be no text nodes with real content
        return array_reduce($children, function ($carry, $child) {
            if (!$carry === false) {
                return false;
            }

            /* @var DOMNode $child */
            return !($child->nodeType === XML_TEXT_NODE && !preg_match('/\S$/', $child->getTextContent()));
        });
    }
1189766
public function getSubnodesByTag($tag)
    {
        return $this
            ->getSubnodes()
            ->filter(function (\Elcodi\Component\Menu\Entity\Menu\Interfaces\NodeInterface $menuNode) use ($tag) {

                return $menuNode->getTag() == $tag;
            });
    }
522229
public function getTagValue($tag)
	{
		if(!$this->hasTag($tag))
		{
			throw new \OutOfBoundsException('Tag ' . $tag . ' is not set');
		}
		
		if(empty($this->tags[$tag]))
		{
			throw new \OutOfBoundsException('Tag ' . $tag . ' does not have a value');
		}
		
		return $this->tags[$tag][0];
	}
108923
public function findByTag($tag)
    {
        return $this->createQueryBuilder('p')
            ->join('p.tags', 't')
            ->where('p.active = true')
            ->andWhere('t.name = :name')
            ->setParameter('name', $tag)
            ->orderBy('p.datePublished', 'DESC')
            ->getQuery()
            ->getResult();
    }
1124400
private function tag_has_default(string $tag){
    return in_array('default', array_values(
      \is_array($this->tags[$tag]) ?
        $this->tags[$tag] :
        $this->tags[$this->tags[$tag]]
    ));
  }
1272185
public static function tagGetVer(string $tag) :?int
        {
            if (!self::$useTagsBuffer || !($ver = (self::$tagsBuffer[$tag] ?? null))) {
                $ver = self::$tagsBuffer[$tag] = self::GetInstance()
                                                     ->get("\$vxnTag:{$tag}") ?: self::tagIncrementVer($tag);
            }

            return $ver ?: null;
        }
1283849
public function get_listener( $tag ) {
		return isset( $this->listeners[ $tag ] ) ? $this->listeners[ $tag ] : new Null_Listener();
	}
650419
public function flushByTag(string $tag): int
    {
        $this->connect();

        $statementHandle = $this->databaseHandle->prepare('DELETE FROM "' . $this->cacheTableName . '" WHERE "context"=? AND "cache"=? AND "identifier" IN (SELECT "identifier" FROM "tags" WHERE "context"=? AND "cache"=? AND "tag"=?)');
        $statementHandle->execute([$this->context(), $this->cacheIdentifier, $this->context(), $this->cacheIdentifier, $tag]);

        $flushed = $statementHandle->rowCount();

        $statementHandle = $this->databaseHandle->prepare('DELETE FROM "' . $this->tagsTableName . '" WHERE "context"=? AND "cache"=? AND "tag"=?');
        $statementHandle->execute([$this->context(), $this->cacheIdentifier, $tag]);

        return $flushed;
    }
1118939
public function get_bbcode($tag)
	{
		if(!isset($this->bbcodes[$tag]))
			return null;

		return $this->bbcodes[$tag];
	}
87025
public function onReplace($tag)
    {
        $chunks = trimsplit('::', $tag);

        if ('news_categories' === $chunks[0]) {
            /** @var Input $input */
            $input = $this->framework->getAdapter(Input::class);

            if ($alias = $input->get($this->manager->getParameterName())) {
                /** @var NewsCategoryModel $model */
                $model = $this->framework->getAdapter(NewsCategoryModel::class);

                if (null !== ($category = $model->findPublishedByIdOrAlias($alias))) {
                    $value = $category->{$chunks[1]};

                    // Convert the binary to UUID for images (#147)
                    if ($chunks[1] === 'image' && $value) {
                        return StringUtil::binToUuid($value);
                    }

                    return $value;
                }
            }
        }

        return false;
    }
823254
protected function getRuleForElement($tag)
    {
        if (isset($this->elements[$tag])) {
            return $this->elements[$tag];
        }
        foreach ($this->elementPatterns as $element) {
            if (preg_match($element->pattern, $tag)) {
                return $element;
            }
        }
        return null;
    }
972052
public function tag($tag)
    {
        $route = $this->factory->createRoute($this, null, array());

        $this->addRoute($route);

        return $route->tag($tag);
    }
59549
public function flushByTag(string $tag): int
    {
        $identifiers = $this->findIdentifiersByTag($tag);
        if (count($identifiers) === 0) {
            return 0;
        }

        foreach ($identifiers as $entryIdentifier) {
            $this->remove($entryIdentifier);
        }
        return count($identifiers);
    }
381794
private static function checkExp($tag)
    {
        return (false !== strpos($tag, ',')) || (false !== strpos($tag, '-')) || (false !== strpos($tag, '/'));
    }