Fixed conditional structure in Person Panel block.

This commit is contained in:
naomi 2018-04-12 15:24:32 +02:00
parent 61c969d7f4
commit 6746b986db

View File

@ -7,7 +7,8 @@ use Drupal\Core\Block\BlockBase;
/**
* Provides a 'PersonPanel' block.
* If the person has no contact details it advises to create them.
* If they have no hats it advises to create them.
* Hats cannot be created without contact details.
* If they have contact details but no hats, it advises to create a hat.
*
* @Block(
* id = "person_panel",
@ -33,8 +34,9 @@ class PersonPanel extends BlockBase {
$markup .= "<p>This person has no contact details yet. To get started, ";
$markup .= "<a class='use-ajax' data-dialog-type='modal' href = $link_to_add>Add a set of contact details</a>";
$markup .= "</p>";
}
} else {
// They have contact details, so they are able to create hats.
// If the person has no hats, suggest they create one, by rendering the hat creator block
$link_to_add = "/zencrm/hat/$person_id/add?destination=/zencrm/person/$person_id";
$hats = \Drupal::entityTypeManager()
@ -44,8 +46,10 @@ class PersonPanel extends BlockBase {
$markup .= "<p>This person has no hats yet. A hat is a role that the person plays in the organisation. To get started, add a hat for this person. </p>";
$plugin_manager = \Drupal::service('plugin.manager.block');
$block = $plugin_manager->createInstance('hat_creator', array());
}
$markup .= render($block->build());
}
}
return [
'#cache' => [
'max-age' => 0,