本文整理匯總了PHP中BaseElementModel::getGroup方法的典型用法代碼示例。如果您正苦於以下問題:PHP BaseElementModel::getGroup方法的具體用法?PHP BaseElementModel::getGroup怎麽用?PHP BaseElementModel::getGroup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類BaseElementModel
的用法示例。
在下文中一共展示了BaseElementModel::getGroup方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: onAfterMoveElementInStructure
/**
* @inheritDoc IElementType::onAfterMoveElementInStructure()
*
* @param BaseElementModel $element
* @param int $structureId
*
* @return null
*/
public function onAfterMoveElementInStructure(BaseElementModel $element, $structureId)
{
// Was the category moved within its group's structure?
if ($element->getGroup()->structureId == $structureId) {
// Update its URI
craft()->elements->updateElementSlugAndUri($element, true, true, true);
// Make sure that each of the category's ancestors are related wherever the category is related
$newRelationValues = array();
$ancestorIds = $element->getAncestors()->ids();
$sources = craft()->db->createCommand()->select('fieldId, sourceId, sourceLocale')->from('relations')->where('targetId = :categoryId', array(':categoryId' => $element->id))->queryAll();
foreach ($sources as $source) {
$existingAncestorRelations = craft()->db->createCommand()->select('targetId')->from('relations')->where(array('and', 'fieldId = :fieldId', 'sourceId = :sourceId', 'sourceLocale = :sourceLocale', array('in', 'targetId', $ancestorIds)), array(':fieldId' => $source['fieldId'], ':sourceId' => $source['sourceId'], ':sourceLocale' => $source['sourceLocale']))->queryColumn();
$missingAncestorRelations = array_diff($ancestorIds, $existingAncestorRelations);
foreach ($missingAncestorRelations as $categoryId) {
$newRelationValues[] = array($source['fieldId'], $source['sourceId'], $source['sourceLocale'], $categoryId);
}
}
if ($newRelationValues) {
craft()->db->createCommand()->insertAll('relations', array('fieldId', 'sourceId', 'sourceLocale', 'targetId'), $newRelationValues);
}
}
}