From 73f072a1c55a3412f20259b3f93caebb16bb888a Mon Sep 17 00:00:00 2001 From: naomi Date: Sat, 14 Apr 2018 18:44:38 +0200 Subject: [PATCH] Created Case Details Block Will use that for sidebar instead of previous Involved Parties block and case details view --- src/Plugin/Block/CaseDetails.php | 58 ++++++++++++++++++++++++++++ src/Plugin/Block/InvolvedParties.php | 40 ------------------- 2 files changed, 58 insertions(+), 40 deletions(-) create mode 100644 src/Plugin/Block/CaseDetails.php delete mode 100644 src/Plugin/Block/InvolvedParties.php diff --git a/src/Plugin/Block/CaseDetails.php b/src/Plugin/Block/CaseDetails.php new file mode 100644 index 0000000..c7430b7 --- /dev/null +++ b/src/Plugin/Block/CaseDetails.php @@ -0,0 +1,58 @@ +getParameter('case_entity')->id(); + $case = $entity = \Drupal::entityTypeManager()->getStorage('case_entity')->load($case_id); + $markup .= $this->renderInvolvedParties($case); + $markup .= $this->renderEntity($case); + $markup .= $this->renderEditLink($case_id); + return [ + '#cache' => [ + 'max-age' => 0, + ], + '#markup' => $markup + ]; + + } + + private function renderEditLink($case_id) { + return ""; + } + + private function renderEntity($case) { + $view_builder = \Drupal::entityTypeManager()->getViewBuilder('case_entity'); + $build = $view_builder->view($case, 'default'); + return render($build); + } + + private function renderInvolvedParties($case) { + $markup = "

Involved Parties

"; + $hats_involved = $case->hats_involved->referencedEntities(); + foreach($hats_involved as $hat) { + $person_id = $hat->person->first()->getValue()['target_id']; + error_log($person_id); + $markup .= "

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

"; + } + return ""; + } + +} diff --git a/src/Plugin/Block/InvolvedParties.php b/src/Plugin/Block/InvolvedParties.php deleted file mode 100644 index ce40a1f..0000000 --- a/src/Plugin/Block/InvolvedParties.php +++ /dev/null @@ -1,40 +0,0 @@ -getParameter('case_entity')->id(); - $markup = ""; - - $case = $entity = \Drupal::entityTypeManager()->getStorage('case_entity')->load($case_id); - $hats_involved = $case->hats_involved->referencedEntities(); - foreach($hats_involved as $hat) { - $person_id = $hat->person->first()->getValue()['target_id']; - $markup .= "

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

"; - } - return [ - '#cache' => [ - 'max-age' => 0, - ], - '#markup' => "" - ]; - - } - -}