Use null coalescing operator in element factory
This commit is contained in:
parent
e45e6e21cf
commit
f1c67c7134
1 changed files with 11 additions and 11 deletions
|
@ -47,18 +47,18 @@ class element_factory {
|
||||||
$classname = '\\customcertelement_' . $element->element . '\\element';
|
$classname = '\\customcertelement_' . $element->element . '\\element';
|
||||||
|
|
||||||
$data = new \stdClass();
|
$data = new \stdClass();
|
||||||
$data->id = isset($element->id) ? $element->id : null;
|
$data->id = $element->id ?? null;
|
||||||
$data->pageid = isset($element->pageid) ? $element->pageid : null;
|
$data->pageid = $element->pageid ?? null;
|
||||||
$data->name = isset($element->name) ? $element->name : get_string('pluginname', 'customcertelement_' . $element->element);
|
$data->name = $element->name ?? get_string('pluginname', 'customcertelement_' . $element->element);
|
||||||
$data->element = $element->element;
|
$data->element = $element->element;
|
||||||
$data->data = isset($element->data) ? $element->data : null;
|
$data->data = $element->data ?? null;
|
||||||
$data->font = isset($element->font) ? $element->font : null;
|
$data->font = $element->font ?? null;
|
||||||
$data->fontsize = isset($element->fontsize) ? $element->fontsize : null;
|
$data->fontsize = $element->fontsize ?? null;
|
||||||
$data->colour = isset($element->colour) ? $element->colour : null;
|
$data->colour = $element->colour ?? null;
|
||||||
$data->posx = isset($element->posx) ? $element->posx : null;
|
$data->posx = $element->posx ?? null;
|
||||||
$data->posy = isset($element->posy) ? $element->posy : null;
|
$data->posy = $element->posy ?? null;
|
||||||
$data->width = isset($element->width) ? $element->width : null;
|
$data->width = $element->width ?? null;
|
||||||
$data->refpoint = isset($element->refpoint) ? $element->refpoint : null;
|
$data->refpoint = $element->refpoint ?? null;
|
||||||
|
|
||||||
// Ensure the necessary class exists.
|
// Ensure the necessary class exists.
|
||||||
if (class_exists($classname)) {
|
if (class_exists($classname)) {
|
||||||
|
|
Loading…
Reference in a new issue