/**
* Method to delete a row from the #__ucm_content table by content_item_id.
*
* @param integer $contentItemId value of the core_content_item_id to delete. Corresponds to the primary key of the content table.
* @param string $typeAlias Alias for the content type
*
* @return boolean True on success.
*
* @since 3.1
* @throws \UnexpectedValueException
*/
public function deleteByContentId($contentItemId = null, $typeAlias = null)
{
$contentItemId = (int) $contentItemId;
if ($contentItemId === 0) {
throw new \UnexpectedValueException('Null content item key not allowed.');
}
if ($typeAlias === null) {
throw new \UnexpectedValueException('Null type alias not allowed.');
}
$db = $this->getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName('core_content_id'))->from($db->quoteName('#__ucm_content'))->where([$db->quoteName('core_content_item_id') . ' = :contentItemId', $db->quoteName('core_type_alias') . ' = :typeAlias'])->bind(':contentItemId', $contentItemId, ParameterType::INTEGER)->bind(':typeAlias', $typeAlias);
$db->setQuery($query);
if ($ucmId = $db->loadResult()) {
return $this->delete($ucmId);
} else {
return true;
}
}