public function getElementState()
{
try {
$state = $this->getWorkflowStateForElement()->getState();
//check for null on new objects
if (is_null($state)) {
$state = $this->workflow->getDefaultState();
}
return $state;
} catch (\Exception $e) {
throw new \Exception('Cannot get state of element.');
}
}