diff --git a/src/Plugin/Block/HatCreator.php b/src/Plugin/Block/HatCreator.php index 6b06160..a29ed9f 100644 --- a/src/Plugin/Block/HatCreator.php +++ b/src/Plugin/Block/HatCreator.php @@ -38,7 +38,7 @@ class HatCreator extends BlockBase { '#cache' => [ 'max-age' => 0, ], - '#markup' => "
$markup
" + '#markup' => "" ]; } diff --git a/src/Plugin/Block/PersonPanel.php b/src/Plugin/Block/PersonPanel.php index b13bd8d..47ecd63 100644 --- a/src/Plugin/Block/PersonPanel.php +++ b/src/Plugin/Block/PersonPanel.php @@ -33,7 +33,7 @@ class PersonPanel extends BlockBase { ->getStorage('contact_details') ->loadByProperties(['person' => $person_id]); if (!reset($contact_details)) { - $markup .= "

This person has no contact details yet. To get started, "; + $markup .= "

This person has no contact details yet. To get started, "; $markup .= "Add a set of contact details"; $markup .= "

"; @@ -45,7 +45,7 @@ class PersonPanel extends BlockBase { ->getStorage('hat') ->loadByProperties(['person' => $person_id]); if (!reset($hats)) { - $markup .= "

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.

"; + $markup .= "

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.

"; $plugin_manager = \Drupal::service('plugin.manager.block'); $block = $plugin_manager->createInstance('hat_creator', array()); $markup .= render($block->build()); @@ -53,7 +53,8 @@ class PersonPanel extends BlockBase { // they have hats, so display the case view for each hat. foreach($hats as $hat) { - $markup .= $this->show_cases_for_hat($hat); + $markup .= $this->showCases($hat); + $markup .= $this->showCaseCreationLinks($hat); } } } @@ -67,11 +68,22 @@ class PersonPanel extends BlockBase { } - private function show_cases_for_hat($hat) { + // Renders a view showing cases that hat is involved in. + private function showCases($hat) { $markup = ''; - $markup .= "

" . $hat->name->getString() . "

"; + $markup .= "

" . $hat->name->getString() . "

"; $markup .= drupal_render(views_embed_view('this_hat_s_cases', 'block_1', $hat->id())); - error_log(print_r(views_embed_view('this_hat_s_cases', 'block_1', $hat->id()), true)); - return $markup; + return "
$markup
"; + } + + // Provides links to create different types of cases, passing in the hat id. + private function showCaseCreationLinks($hat) { + $hat_id = $hat->id(); + $case_types = \Drupal::service('entity_type.bundle.info')->getBundleInfo('case_entity'); + foreach($case_types as $case_type_id => $type) { + $label = $type['label']; + $markup .= "

Add a $label Case

"; + } + return ""; } }