/**
* Method to untag an item
*
* @param integer $contentId ID of the content item being untagged
* @param TableInterface $table Table object being untagged
* @param array $tags Array of tags to be untagged. Use an empty array to untag all existing tags.
*
* @return boolean true on success, otherwise false.
*
* @since 3.1
*/
public function unTagItem($contentId, TableInterface $table, $tags = array())
{
$key = $table->getKeyName();
$id = (int) $table->{$key};
$db = Factory::getDbo();
$query = $db->getQuery(true)->delete($db->quoteName('#__contentitem_tag_map'))->where([$db->quoteName('type_alias') . ' = :type', $db->quoteName('content_item_id') . ' = :id'])->bind(':type', $this->typeAlias)->bind(':id', $id, ParameterType::INTEGER);
if (\is_array($tags) && \count($tags) > 0) {
$tags = ArrayHelper::toInteger($tags);
$query->whereIn($db->quoteName('tag_id'), $tags);
}
$db->setQuery($query);
return (bool) $db->execute();
}