Added bundle labels to cases & activities views
This involved creating access control handlers for cases and activities (also did one for actors for good measure) and regenerating the opencase_features_opencase_ui feature so as to add the "type" field to the views
This commit is contained in:
@ -11,6 +11,7 @@ use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
|
||||
* id = "oc_activity_type",
|
||||
* label = @Translation("Activity type"),
|
||||
* handlers = {
|
||||
* "access" = "Drupal\opencase_entities\OCActivityTypeAccessControlHandler",
|
||||
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
|
||||
* "list_builder" = "Drupal\opencase_entities\OCActivityTypeListBuilder",
|
||||
* "form" = {
|
||||
|
@ -11,6 +11,7 @@ use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
|
||||
* id = "oc_actor_type",
|
||||
* label = @Translation("Actor type"),
|
||||
* handlers = {
|
||||
* "access" = "Drupal\opencase_entities\OCActorTypeAccessControlHandler",
|
||||
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
|
||||
* "list_builder" = "Drupal\opencase_entities\OCActorTypeListBuilder",
|
||||
* "form" = {
|
||||
|
@ -11,6 +11,7 @@ use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
|
||||
* id = "oc_case_type",
|
||||
* label = @Translation("Case type"),
|
||||
* handlers = {
|
||||
* "access" = "Drupal\opencase_entities\OCCaseTypeAccessControlHandler",
|
||||
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
|
||||
* "list_builder" = "Drupal\opencase_entities\OCCaseTypeListBuilder",
|
||||
* "form" = {
|
||||
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\opencase_entities;
|
||||
|
||||
use Drupal\Core\Entity\EntityAccessControlHandler;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Access\AccessResult;
|
||||
|
||||
/**
|
||||
* Defines the access control handler for the OCActivityType Config Entity.
|
||||
* Always allows viewing the label of the bundle.
|
||||
*
|
||||
* @see Drupal\opencase_entities\Entity\OCActivityType
|
||||
*/
|
||||
class OCActivityTypeAccessControlHandler extends EntityAccessControlHandler {
|
||||
|
||||
protected $viewLabelOperation = TRUE;
|
||||
|
||||
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
|
||||
if ($operation == 'view label') {
|
||||
return AccessResult::allowed();
|
||||
}
|
||||
return parent::checkAccess();
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\opencase_entities;
|
||||
|
||||
use Drupal\Core\Entity\EntityAccessControlHandler;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Access\AccessResult;
|
||||
|
||||
/**
|
||||
* Defines the access control handler for the OCActorType Config Entity.
|
||||
* Always allows viewing the label of the bundle.
|
||||
*
|
||||
* @see Drupal\opencase_entities\Entity\OCActorType
|
||||
*/
|
||||
class OCActorTypeAccessControlHandler extends EntityAccessControlHandler {
|
||||
|
||||
protected $viewLabelOperation = TRUE;
|
||||
|
||||
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
|
||||
if ($operation == 'view label') {
|
||||
return AccessResult::allowed();
|
||||
}
|
||||
return parent::checkAccess();
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\opencase_entities;
|
||||
|
||||
use Drupal\Core\Entity\EntityAccessControlHandler;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Access\AccessResult;
|
||||
|
||||
/**
|
||||
* Defines the access control handler for the OCCaseType Config Entity.
|
||||
* Always allows viewing the label of the bundle.
|
||||
*
|
||||
* @see Drupal\opencase_entities\Entity\OCCaseType
|
||||
*/
|
||||
class OCCaseTypeAccessControlHandler extends EntityAccessControlHandler {
|
||||
|
||||
protected $viewLabelOperation = TRUE;
|
||||
|
||||
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
|
||||
if ($operation == 'view label') {
|
||||
return AccessResult::allowed();
|
||||
}
|
||||
return parent::checkAccess();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user