Add case block is working

This commit is contained in:
naomi 2022-07-07 12:54:42 +01:00
parent 2b4b9696db
commit 07683cd1b8
2 changed files with 1 additions and 42 deletions

View File

@ -1,40 +0,0 @@
<?php
namespace Drupal\opencase_cases\Plugin\Block;
use Drupal\Core\Block\BlockBase;
/**
* Provides a Block for adding a case for the current client
*
* @Block(
* id = "add_case",
* admin_label = @Translation("Add Case"),
* category = @Translation("Opencase"),
* )
*/
class AddCase extends BlockBase {
/**
* {@inheritdoc}
*/
public function build():array {
$target_id = \Drupal::routeMatch()->getParameter('oc_actor')->id();
$case_types = \Drupal::service('entity_type.bundle.info')->getBundleInfo('oc_case');
$markup = "<ul>";
foreach($case_types as $id => $info) {
$label = $info['label'];
$markup .= "<li><a href='/opencase/oc_case/add/$id?target_id=$target_id'>$label</a></li>";
}
$markup .= "</ul>";
return array(
'#markup' => $markup
);
}
public function getCacheMaxAge():int {
return 0;
}
}

View File

@ -26,8 +26,7 @@ class AddCase extends BlockBase {
$case_types = $this->getCaseTypesToDisplay($actorType);
foreach($case_types as $id => $info) {
$label = $info['label'];
$markup .= "foo";
#$markup .= "<li><a href='/opencase/oc_case/add/$id?target_id=$target_id&destination=/opencase/oc_actor/$target_id'>$label</a></li>";
$markup .= "<li><a href='/opencase/oc_case/add/$id?target_id=$target_id&destination=/opencase/oc_actor/$target_id'>$label</a></li>";
}
$markup .= "</ul>";
return array('#markup' => $markup);