Added case list view & a block for adding cases
This commit is contained in:
40
modules/opencase_cases/src/Plugin/Block/AddCase.php
Normal file
40
modules/opencase_cases/src/Plugin/Block/AddCase.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user