public static function factory(array $options)
{
$id = elgg_extract('id', $options);
$definition = new WidgetDefinition($id);
$name = elgg_extract('name', $options);
if (empty($name)) {
if (elgg_language_key_exists("widgets:{$id}:name")) {
$definition->name = elgg_echo("widgets:{$id}:name");
} elseif (elgg_language_key_exists($id)) {
$definition->name = elgg_echo($id);
} else {
$definition->name = $id;
}
} else {
$definition->name = $name;
}
$description = elgg_extract('description', $options);
if (empty($description)) {
if (elgg_language_key_exists("widgets:{$id}:description")) {
$definition->description = elgg_echo("widgets:{$id}:description");
}
} else {
$definition->description = $description;
}
$context = (array) elgg_extract('context', $options, ['all']);
if (in_array('all', $context)) {
$context[] = 'profile';
$context[] = 'dashboard';
_elgg_services()->logger->notice("The widget '{$id}' need to be registered for explicit contexts");
$pos = array_search('all', $context);
unset($context[$pos]);
$context = array_unique($context);
}
$definition->context = $context;
$definition->multiple = (bool) elgg_extract('multiple', $options, false);
return $definition;
}