src/Model/Behavior/TagBehavior.php
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;
	}
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;
	}
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 ; }
Checks if a tag already exists and returns the id if yes.

@param string $tag Tag key.
@return null|int
Checks if a tag already exists and returns the id if yes .