本文整理汇总了PHP中ElggObject::getAnswers方法的典型用法代码示例。如果您正苦于以下问题:PHP ElggObject::getAnswers方法的具体用法?PHP ElggObject::getAnswers怎么用?PHP ElggObject::getAnswers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ElggObject
的用法示例。
在下文中一共展示了ElggObject::getAnswers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateQuestion
/**
* After the question is updated in the databse make sure the answers have the same access_id
*
* @param string $event the name of the event
* @param string $type the type of the event
* @param \ElggObject $entity the affected object
*
* @return void
*/
public static function updateQuestion($event, $type, $entity)
{
if (!$entity instanceof \ElggQuestion) {
return;
}
$org_attributes = $entity->getOriginalAttributes();
if (elgg_extract('access_id', $org_attributes) === null) {
// access wasn't updated
return;
}
// ignore access for this part
$ia = elgg_set_ignore_access(true);
// get all the answers for this question
$answers = $entity->getAnswers(['limit' => false]);
if (empty($answers)) {
// restore access
elgg_set_ignore_access($ia);
return;
}
/* @var $answer \ElggAnswer */
foreach ($answers as $answer) {
// update the access_id with the questions access_id
$answer->access_id = $entity->access_id;
$answer->save();
}
// restore access
elgg_set_ignore_access($ia);
}