Commit 27434f3a authored by Nigel McNie's avatar Nigel McNie
Browse files

Make LeapExportElement::assign_smarty_vars throw an exception if called...

Make LeapExportElement::assign_smarty_vars throw an exception if called without the artefact field being set.

It seems this class can be used in two ways. In one way, it represents
one artefact being converted to an entry. The other way is where
something that isn't an artefact is being converted (e.g. a resume
"psuedo artefact"). Which is a bit naff, but no time to fix right now.
Instead, make this method die horribly if it's called directly. All
current callers override this method without calling the parent anyway.
Signed-off-by: default avatarNigel McNie <>
parent b594cad8
......@@ -462,6 +462,15 @@ class LeapExportElement {
* assign the smarty vars used in this template
public function assign_smarty_vars() {
if (!($this->artefact instanceof ArtefactType)) {
// If you're seeing this error, this means you have subclassed
// LeapExportElement and are using it to represent something more
// than just one artefact. In this case, you must override this
// method.
throw new ImportException("LeapExportElement::assign_smarty_vars was called with null artefact. "
. "If you are using LeapExportElement as a dummy class for exporting more than one artefact, "
. "you must override assign_smarty_vars yourself.");
$this->smarty->assign('artefacttype', $this->artefact->get('artefacttype'));
$this->smarty->assign('artefactplugin', $this->artefact->get_plugin_name());
$this->smarty->assign('title', $this->artefact->get('title'));
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment