本文整理汇总了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);
}
}
}