Fixed conditional structure in Person Panel block.
This commit is contained in:
parent
61c969d7f4
commit
6746b986db
@ -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,19 +34,22 @@ 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()
|
||||
->getStorage('hat')
|
||||
->loadByProperties(['person' => $person_id]);
|
||||
if (!reset($hats)) {
|
||||
$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());
|
||||
}
|
||||
}
|
||||
|
||||
// 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()
|
||||
->getStorage('hat')
|
||||
->loadByProperties(['person' => $person_id]);
|
||||
if (!reset($hats)) {
|
||||
$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,
|
||||
|
Reference in New Issue
Block a user