Skip to content

Commit

Permalink
Delete UCM content entries when Joomla articles are deleted (joomla#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonge authored and rdeutz committed Jan 15, 2017
1 parent 4477944 commit 0bc385d
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions libraries/cms/helper/tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,22 +362,37 @@ public function createTagsFromMetadata($metadata)
* Method to delete the tag mappings and #__ucm_content record for for an item
*
* @param JTableInterface $table JTable object of content table where delete occurred
* @param integer $contentItemId ID of the content item.
* @param integer|array $contentItemId ID of the content item. Or an array of key/value pairs with array key
* being a primary key name and value being the content item ID. Note
* multiple primary keys are not supported
*
* @return boolean true on success, false on failure
*
* @since 3.1
* @throws InvalidArgumentException
*/
public function deleteTagData(JTableInterface $table, $contentItemId)
{
$result = $this->unTagItem($contentItemId, $table);
$key = $table->getKeyName();

/**
* @var JTableCorecontent $ucmContentTable
*/
if (!is_array($contentItemId))
{
$contentItemId = array($key => $contentItemId);
}

// If we have multiple items for the content item primary key we currently don't support this so
// throw an InvalidArgumentException for now
if (count($contentItemId) != 1)
{
throw new InvalidArgumentException('Multiple primary keys are not supported as a content item id');
}

$result = $this->unTagItem($contentItemId[$key], $table);

/** @var JTableCorecontent $ucmContentTable */
$ucmContentTable = JTable::getInstance('Corecontent');

return $result && $ucmContentTable->deleteByContentId($contentItemId, $this->typeAlias);
return $result && $ucmContentTable->deleteByContentId($contentItemId[$key], $this->typeAlias);
}

/**
Expand Down

0 comments on commit 0bc385d

Please sign in to comment.