public static function OpignoTinCanApiStatements::contextSetParents in Opigno TinCan API 3.x
Same name and namespace in other branches
- 8 src/OpignoTinCanApiStatements.php \Drupal\opigno_tincan_api\OpignoTinCanApiStatements::contextSetParents()
Sets context parents.
Parameters
\TinCan\Context $context: The context to add the parents.
array $group_ids: The nodes IDs to add as parents.
null|string $definition_type: Definition type.
Return value
\TinCan\Context Context.
2 calls to OpignoTinCanApiStatements::contextSetParents()
- _opigno_tincan_activities_create_and_send_statements in modules/
opigno_tincan_activities/ opigno_tincan_activities.module - The main function for building tincan statement object for opigno activity.
- _opigno_tincan_badges_create_and_send_statements in modules/
opigno_tincan_badges/ opigno_tincan_badges.module - Function for creating and sending tincan statemens when user get a badge.
File
- src/
OpignoTinCanApiStatements.php, line 149
Class
- OpignoTinCanApiStatements
- Class OpignoTinCanApiStatements.
Namespace
Drupal\opigno_tincan_apiCode
public static function contextSetParents(Context &$context, array $group_ids, $definition_type = NULL) {
$parents = [];
foreach ($group_ids as $group_id) {
$parent = [];
$options = [
'absolute' => TRUE,
];
$url = Url::fromRoute('entity.group.canonical', [
'group' => $group_id,
], $options)
->toString();
$parent['id'] = $url;
if (!empty($definition_type)) {
$parent['definition'] = [
'type' => $definition_type,
];
}
$parents[] = $parent;
}
if (!empty($parents)) {
$context
->getContextActivities()
->setParent($parents);
}
return $context;
}