本文整理汇总了PHP中BaseObject::getTags方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseObject::getTags方法的具体用法?PHP BaseObject::getTags怎么用?PHP BaseObject::getTags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseObject
的用法示例。
在下文中一共展示了BaseObject::getTags方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkExistForDelete
/**
* Function which checks the object tags agains DB
* and returns an array of tags ids which need to be deleted.
* @param BaseObject $object
* @return array
*/
protected function checkExistForDelete(BaseObject $object, $tagsToCheck = null)
{
$objectTags = $tagsToCheck ? $this->trimObjectTags($tagsToCheck) : $this->trimObjectTags($object->getTags());
$objectTags = str_replace(self::$specialCharacters, self::$specialCharactersReplacement, $objectTags);
$tagsToKeep = array();
foreach ($objectTags as $objectTag) {
$peer = $object->getPeer();
$c = KalturaCriteria::create(get_class($object));
$c->addAnd(self::PARTNER_ID_FIELD, $object->getPartnerId(), KalturaCriteria::EQUAL);
$c->addAnd($peer::TAGS, $objectTag, KalturaCriteria::LIKE);
$c->addAnd($peer::ID, array($object->getId()), KalturaCriteria::NOT_IN);
$selectResults = $peer->doSelect($c);
foreach ($selectResults as $selectResult) {
$resultTags = $this->trimObjectTags($selectResult->getTags());
if (in_array($objectTag, $resultTags)) {
// if(isset($tagsToKeep[$objectTag]))
// $tagsToKeep[$objectTag]++;
// else
// $tagsToKeep[$objectTag] = 1;
if (!in_array($objectTag, $tagsToKeep)) {
$tagsToKeep[] = $objectTag;
}
}
}
}
KalturaLog::debug("tags to keep: " . print_r($tagsToKeep, true));
if (count($tagsToKeep)) {
//Decrement instance count for the tags that we keep
$c = self::getTagObjectsByTagStringsCriteria($tagsToKeep, $this->getObjectIdByClassName(get_class($object)), $object->getPartnerId());
$tagsToKeepObjects = TagPeer::doSelect($c);
foreach ($tagsToKeepObjects as $tagToKeepObject) {
/* @var $tagToKeepObject Tag */
$tagToKeepObject->decrementInstanceCount();
}
}
//Return the IDs of the rest of the tags for removal.
$tagsToRemove = array_diff($objectTags, $tagsToKeep);
KalturaLog::debug("tags to delete: " . print_r($tagsToRemove, true));
if ($tagsToRemove) {
$c = self::getTagObjectsByTagStringsCriteria($tagsToRemove, $this->getObjectIdByClassName(get_class($object)), $object->getPartnerId());
$c->applyFilters();
$recordsToRemove = $c->getRecordsCount();
return $c->getFetchedIds();
}
return array();
}
示例2: objectChanged
public function objectChanged(BaseObject $object, array $modifiedColumns)
{
$privacyContexts = null;
if ($object instanceof entry) {
$criteria = new Criteria();
$criteria->add(categoryEntryPeer::ENTRY_ID, $object->getId());
$categoryEntries = categoryEntryPeer::doSelect($criteria);
$privacyContexts = array(self::NULL_PC);
if (count($categoryEntries)) {
foreach ($categoryEntries as $categoryEntry) {
/* @var $categoryEntry categoryEntry */
if ($categoryEntry->getPrivacyContext() != "") {
$privacyContexts = array_merge($privacyContexts, self::trimObjectTags($categoryEntry->getPrivacyContext()));
} else {
$privacyContexts[] = kEntitlementUtils::DEFAULT_CONTEXT;
}
}
$privacyContexts = array_unique($privacyContexts);
}
}
$oldTags = $object->getColumnsOldValue(self::getClassConstValue(get_class($object->getPeer()), self::TAGS_FIELD_NAME));
$newTags = $object->getTags();
$tagsForDelete = implode(',', array_diff(explode(',', $oldTags), explode(',', $newTags)));
$tagsForUpdate = implode(',', array_diff(explode(',', $newTags), explode(',', $oldTags)));
if ($oldTags && $oldTags != "") {
self::decrementExistingTagsInstanceCount($tagsForDelete, $object->getPartnerId(), get_class($object), $privacyContexts);
}
self::addOrIncrementTags($tagsForUpdate, $object->getPartnerId(), get_class($object), $privacyContexts);
}