public bool
tagItem
(mixed $ucmId, \Joomla\CMS\Table\TableInterface $table, mixed $tags = array(), mixed $replace = true)
/**
* Method to add or update tags associated with an item.
*
* @param integer $ucmId Id of the #__ucm_content item being tagged
* @param TableInterface $table Table object being tagged
* @param array $tags Array of tags to be applied.
* @param boolean $replace Flag indicating if all existing tags should be replaced
*
* @return boolean true on success, otherwise false.
*
* @since 3.1
*/
public function tagItem($ucmId, TableInterface $table, $tags = array(), $replace = true)
{
$key = $table->get('_tbl_key');
$oldTags = $this->getTagIds((int) $table->{$key}, $this->typeAlias);
$oldTags = explode(',', $oldTags);
$result = $this->unTagItem($ucmId, $table);
if ($replace) {
$newTags = $tags;
} else {
if ($tags == array()) {
$newTags = $table->newTags;
} else {
$newTags = $tags;
}
if ($oldTags[0] != '') {
$newTags = array_unique(array_merge($newTags, $oldTags));
}
}
if (\is_array($newTags) && \count($newTags) > 0 && $newTags[0] != '') {
$result = $result && $this->addTagMapping($ucmId, $table, $newTags);
}
return $result;
}