diff --git a/modules/core/owner/farm_owner.install b/modules/core/owner/farm_owner.install deleted file mode 100644 index c6e77a1cc..000000000 --- a/modules/core/owner/farm_owner.install +++ /dev/null @@ -1,85 +0,0 @@ - t('Assigned to'), - 'description' => t('Optionally assign this task to one or more people.'), - 'target_type' => 'user', - 'multiple' => TRUE, - 'weight' => [ - 'form' => -70, - 'view' => -70, - ], - ]; - $handler = 'default:user'; - $handler_settings = [ - 'include_anonymous' => FALSE, - 'filter' => [ - 'type' => '_none', - ], - 'target_bundles' => NULL, - 'sort' => [ - 'field' => '_none', - ], - 'auto_create' => FALSE, - ]; - $form_display_options = [ - 'type' => 'options_select', - 'weight' => $options['weight']['form'] ?? 0, - ]; - $view_display_options = [ - 'label' => 'inline', - 'type' => 'entity_reference_label', - 'weight' => $options['weight']['view'] ?? 0, - 'settings' => [ - 'link' => TRUE, - ], - ]; - $field_storage_definition = BaseFieldDefinition::create('entity_reference') - ->setLabel(t('Assigned to')) - ->setDescription(t('Optionally assign this task to one or more people.')) - ->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) - ->setSetting('target_type', 'user') - ->setSetting('handler', $handler) - ->setSetting('handler_settings', $handler_settings) - ->setDisplayOptions('form', $form_display_options) - ->setDisplayOptions('view', $view_display_options); - - // $field_storage_definition = \Drupal::service('farm_field.factory')->baseFieldDefinition($field_info); - $entity_type = 'asset'; - \Drupal::entityDefinitionUpdateManager() - ->installFieldStorageDefinition($field_name, $entity_type, $entity_type, $field_storage_definition); - - - - // Create action for assigning assets to users. - $action = Action::create([ - 'id' => 'asset_assign_action', - 'label' => t('Assign asset'), - 'type' => 'asset', - 'plugin' => 'asset_assign_action', - 'configuration' => [], - ]); - $action->save(); - -} - -/* - * Add the assign owner to asset configuration for bulk assigns - */ -// function hook_post_update_add_asset_owner() { - -// } \ No newline at end of file diff --git a/modules/core/owner/farm_owner.post_update.php b/modules/core/owner/farm_owner.post_update.php new file mode 100644 index 000000000..71e8352d6 --- /dev/null +++ b/modules/core/owner/farm_owner.post_update.php @@ -0,0 +1,43 @@ + 'entity_reference', + 'label' => t('Assigned to'), + 'description' => t('Optionally assign this task to one or more people.'), + 'target_type' => 'user', + 'multiple' => TRUE, + 'weight' => [ + 'form' => -70, + 'view' => -70, + ], + ]; + $field_definition = \Drupal::service('farm_field.factory')->baseFieldDefinition($field_info); + \Drupal::entityDefinitionUpdateManager() + ->installFieldStorageDefinition($field_name, $entity_type, $module_name, $field_definition); + + // Create action for assigning assets to users. + $action = Action::create([ + 'id' => 'asset_assign_action', + 'label' => t('Assign asset'), + 'type' => 'asset', + 'plugin' => 'asset_assign_action', + 'configuration' => [], + ]); + $action->save(); +} \ No newline at end of file