Added controller for creating new cases.
This commit is contained in:
parent
12ccecdd55
commit
109c3e14c9
34
src/Controller/CaseController.php
Normal file
34
src/Controller/CaseController.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\zencrm\Controller;
|
||||||
|
|
||||||
|
use Drupal\Core\Controller\ControllerBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class CaseController.
|
||||||
|
*/
|
||||||
|
class CaseController extends ControllerBase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays a form for creating a case.
|
||||||
|
* The type of case and the hat are prepopulated.
|
||||||
|
*
|
||||||
|
* @return form for creating a case
|
||||||
|
*/
|
||||||
|
public function createCaseForHat($hat_id, $case_type_id) {
|
||||||
|
$values = array(
|
||||||
|
'type' => $case_type_id,
|
||||||
|
);
|
||||||
|
|
||||||
|
$case = \Drupal::entityTypeManager()
|
||||||
|
->getStorage('case_entity')
|
||||||
|
->create($values);
|
||||||
|
|
||||||
|
$case->hats_involved->appendItem($hat_id);
|
||||||
|
|
||||||
|
$form = \Drupal::entityTypeManager()
|
||||||
|
->getFormObject('case_entity', 'default')
|
||||||
|
->setEntity($case);
|
||||||
|
return \Drupal::formBuilder()->getForm($form);
|
||||||
|
}
|
||||||
|
}
|
@ -21,3 +21,12 @@ zencrm.contact_details.create:
|
|||||||
_title: 'Add New Contact Details'
|
_title: 'Add New Contact Details'
|
||||||
requirements:
|
requirements:
|
||||||
_permission: 'access content'
|
_permission: 'access content'
|
||||||
|
|
||||||
|
zencrm.case.create:
|
||||||
|
path: '/zencrm/case/{hat_id}/add/{case_type_id}'
|
||||||
|
defaults:
|
||||||
|
_controller: '\Drupal\zencrm\Controller\CaseController::createCaseForHat'
|
||||||
|
_title: 'Add New Case'
|
||||||
|
requirements:
|
||||||
|
_permission: 'access content'
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user