/**
* Function that handles saving tags used in a table class after a store()
*
* @param TableInterface $table Table being processed
* @param array $newTags Array of new tags
* @param boolean $replace Flag indicating if all existing tags should be replaced
*
* @return boolean
*
* @since 3.1
*/
public function postStoreProcess(TableInterface $table, $newTags = array(), $replace = true)
{
if (!empty($table->newTags) && empty($newTags)) {
$newTags = $table->newTags;
}
// If existing row, check to see if tags have changed.
$newTable = clone $table;
$newTable->reset();
$result = true;
// Process ucm_content and ucm_base if either tags have changed or we have some tags.
if ($this->tagsChanged || !empty($newTags) && $newTags[0] != '') {
if (!$newTags && $replace == true) {
// Delete all tags data
$key = $table->getKeyName();
$result = $this->deleteTagData($table, $table->{$key});
} else {
// Process the tags
$data = $this->getRowData($table);
$ucmContentTable = Table::getInstance('Corecontent');
$ucm = new UCMContent($table, $this->typeAlias);
$ucmData = $data ? $ucm->mapData($data) : $ucm->ucmData;
$primaryId = $ucm->getPrimaryKey($ucmData['common']['core_type_id'], $ucmData['common']['core_content_item_id']);
$result = $ucmContentTable->load($primaryId);
$result = $result && $ucmContentTable->bind($ucmData['common']);
$result = $result && $ucmContentTable->check();
$result = $result && $ucmContentTable->store();
$ucmId = $ucmContentTable->core_content_id;
// Store the tag data if the article data was saved and run related methods.
$result = $result && $this->tagItem($ucmId, $table, $newTags, $replace);
}
}
return $result;
}