Fixed bugs to do with entity type relations widget
This commit is contained in:
parent
dbc38e8f61
commit
260979edcc
@ -10,7 +10,7 @@ use Drupal\Core\Field\BaseFieldDefinition;
|
|||||||
use Drupal\Core\Routing\RouteMatchInterface;
|
use Drupal\Core\Routing\RouteMatchInterface;
|
||||||
use Drupal\user\Entity\Role;
|
use Drupal\user\Entity\Role;
|
||||||
use Drupal\user\RoleInterface;
|
use Drupal\user\RoleInterface;
|
||||||
use Drupal\opencase\EntityTypeRelationsWidget;
|
use Drupal\opencase_defaults\EntityTypeRelationsWidget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements hook_help().
|
* Implements hook_help().
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Drupal\opencase;
|
namespace Drupal\opencase_defaults;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stuff to do with the relationship of case types to actor types, and activity types to case types
|
* Stuff to do with the relationship of case types to actor types, and activity types to case types
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Drupal\opencase;
|
namespace Drupal\opencase_defaults;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages GUI for configuring relations between case types and actor types, or activity types and case types
|
* Manages GUI for configuring relations between case types and actor types, or activity types and case types
|
||||||
@ -46,8 +46,8 @@ class EntityTypeRelationsWidget {
|
|||||||
*/
|
*/
|
||||||
public function populate(&$form) {
|
public function populate(&$form) {
|
||||||
$case_type = $form['id']['#default_value'];
|
$case_type = $form['id']['#default_value'];
|
||||||
$allowedActorTypes = EntityTypeRelations::getAllowedActorTypesForCaseType($case_type);
|
# $allowedActorTypes = EntityTypeRelations::getAllowedActorTypesForCaseType($case_type);
|
||||||
$form['allowed_actor_types']['#default_value'] = $allowedActorTypes;
|
# $form['allowed_actor_types']['#default_value'] = $allowedActorTypes;
|
||||||
$allowedActivityTypes = EntityTypeRelations::getAllowedActivityTypesForCaseType($case_type);
|
$allowedActivityTypes = EntityTypeRelations::getAllowedActivityTypesForCaseType($case_type);
|
||||||
$form['allowed_activity_types']['#default_value'] = $allowedActivityTypes;
|
$form['allowed_activity_types']['#default_value'] = $allowedActivityTypes;
|
||||||
}
|
}
|
||||||
@ -61,14 +61,14 @@ class EntityTypeRelationsWidget {
|
|||||||
*/
|
*/
|
||||||
public function submit($form, $form_state) {
|
public function submit($form, $form_state) {
|
||||||
$case_type_machine_name = $form['id']['#default_value'] ? $form['id']['#default_value'] : $form_state->getValue('id');
|
$case_type_machine_name = $form['id']['#default_value'] ? $form['id']['#default_value'] : $form_state->getValue('id');
|
||||||
$base_field_override = \Drupal\Core\Field\Entity\BaseFieldOverride::load("oc_case.$case_type_machine_name.actors_involved");
|
# $base_field_override = \Drupal\Core\Field\Entity\BaseFieldOverride::load("oc_case.$case_type_machine_name.actors_involved");
|
||||||
if (!$base_field_override) {
|
# if (!$base_field_override) {
|
||||||
$entity_fields = \Drupal::service('entity_field.manager')->getBaseFieldDefinitions('oc_case');
|
# $entity_fields = \Drupal::service('entity_field.manager')->getBaseFieldDefinitions('oc_case');
|
||||||
$field_definition = $entity_fields['actors_involved'];
|
# $field_definition = $entity_fields['actors_involved'];
|
||||||
$base_field_override = \Drupal\Core\field\Entity\BaseFieldOverride::createFromBaseFieldDefinition($field_definition, $case_type_machine_name);
|
# $base_field_override = \Drupal\Core\field\Entity\BaseFieldOverride::createFromBaseFieldDefinition($field_definition, $case_type_machine_name);
|
||||||
}
|
# }
|
||||||
$base_field_override->setSetting('handler_settings', ['target_bundles' => $form_state->getValue('allowed_actor_types')]);
|
# $base_field_override->setSetting('handler_settings', ['target_bundles' => $form_state->getValue('allowed_actor_types')]);
|
||||||
$base_field_override->save();
|
# $base_field_override->save();
|
||||||
$caseTypeConfig = \Drupal::entityTypeManager()->getStorage('oc_case_type')->load($case_type_machine_name);
|
$caseTypeConfig = \Drupal::entityTypeManager()->getStorage('oc_case_type')->load($case_type_machine_name);
|
||||||
$caseTypeConfig->set('allowedActivityTypes', $form_state->getValue('allowed_activity_types'));
|
$caseTypeConfig->set('allowedActivityTypes', $form_state->getValue('allowed_activity_types'));
|
||||||
$caseTypeConfig->save();
|
$caseTypeConfig->save();
|
||||||
|
Reference in New Issue
Block a user