This repository has been archived on 2022-07-12. You can view files and clone it, but cannot push or open issues or pull requests.
opencase/src/EntityTypeRelations.php

28 lines
1.0 KiB
PHP
Raw Normal View History

<?php
namespace Drupal\opencase;
/**
* Stuff to do with the relationship of case types to actor types, and activity types to case types
*
*/
class EntityTypeRelations {
public static function getAllowedActorTypesForCaseType($case_type) {
$base_field_override = \Drupal\Core\Field\Entity\BaseFieldOverride::load("oc_case.$case_type.actors_involved");
$allowedActorTypes = array();
if ($base_field_override) {
2018-06-13 15:51:14 +00:00
$allowedActorTypes = $base_field_override->getSettings()['handler_settings']['target_bundles'];
}
2018-06-13 15:51:14 +00:00
return $allowedActorTypes; // // format: ['volunteer' => 0, 'client' => 'client']
}
2018-06-13 15:51:14 +00:00
public static function getAllowedActivityTypesForCaseType($case_type) {
$caseTypeConfig = \Drupal::entityTypeManager()->getStorage('oc_case_type')->load($case_type);
$allowedActivityTypes = $caseTypeConfig->get('allowedActivityTypes'); // format: ['application' => 'application', 'interview' => 0]
if (!$allowedActivityTypes) $allowedActivityTypes = array();
return $allowedActivityTypes;
2018-06-13 15:51:14 +00:00
}
}