-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dependabot/composer/drupal/config_update-2.0…
….0-alpha4
- Loading branch information
Showing
16 changed files
with
781 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
modules/custom/az_person/az_person_profiles_import/az_person_profiles_import.info.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: 'Quickstart Person Profiles Import' | ||
type: module | ||
description: 'Import people via UA Vitae Profiles.' | ||
core_version_requirement: ^9 || ^10 | ||
package: 'The University of Arizona - Experimental' | ||
dependencies: | ||
- az_person | ||
- field | ||
- migrate | ||
- migrate_plus | ||
- migrate_tools | ||
- node | ||
- path | ||
- pathauto |
12 changes: 12 additions & 0 deletions
12
modules/custom/az_person/az_person_profiles_import/az_person_profiles_import.links.task.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
az_person_profiles_import.import_tab: | ||
title: 'Import Person' | ||
route_name: az_person_profiles_import.form | ||
parent_id: system.admin_content | ||
description: 'Import a person from the Profiles API' | ||
weight: 102 | ||
|
||
az_person_profiles_import.settings_tab: | ||
route_name: az_person_profiles_import.settings_form | ||
title: 'Profiles Integration' | ||
base_route: az_core.az_settings | ||
weight: 6 |
52 changes: 52 additions & 0 deletions
52
modules/custom/az_person/az_person_profiles_import/az_person_profiles_import.module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Contains az_person_profiles_import.module. | ||
*/ | ||
|
||
use Drupal\Core\Entity\EntityInterface; | ||
use Drupal\field\Entity\FieldStorageConfig; | ||
use Drupal\node\Entity\Node; | ||
|
||
/** | ||
* Implements hook_entity_presave(). | ||
*/ | ||
function az_person_profiles_import_node_presave(EntityInterface $entity) { | ||
$fields = [ | ||
'field_az_fname', | ||
'field_az_lname', | ||
'field_az_netid', | ||
'field_az_email', | ||
'field_az_body', | ||
'field_az_titles', | ||
'field_az_degrees', | ||
'field_az_phones', | ||
]; | ||
// Set a new revision to be created if this is a migrating profile. | ||
// Nodes from migrations are isSyncing(). | ||
if (($entity instanceof Node) && ($entity->bundle() === 'az_person') && $entity->isSyncing() && !$entity->isNew()) { | ||
// Create new revision on syncing person records. | ||
$revision_log = 'Updated from profiles import.'; | ||
foreach ($fields as $field) { | ||
if ($entity->hasField($field) && !empty($entity->original)) { | ||
// Check if field changed. | ||
$value = $entity->get($field)->getValue(); | ||
$original = $entity->original->get($field)->getValue(); | ||
if (serialize($value) !== serialize($original)) { | ||
// Field value has changed. | ||
// Get human readable name of field. | ||
$field_info = FieldStorageConfig::loadByName('node', $field); | ||
if (!is_null($field_info)) { | ||
$label = $field_info->getLabel(); | ||
// Add mention of field being changed in log message. | ||
$revision_log .= " Modified field " . $label . '.'; | ||
} | ||
} | ||
} | ||
} | ||
$entity->setNewRevision(TRUE); | ||
$entity->setRevisionLogMessage($revision_log); | ||
$entity->isDefaultRevision(TRUE); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
modules/custom/az_person/az_person_profiles_import/az_person_profiles_import.routing.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
az_person_profiles_import.settings_form: | ||
path: '/admin/config/az-quickstart/settings/az-person-profiles-import' | ||
defaults: | ||
_title: 'Profiles Import Settings' | ||
_form: 'Drupal\az_person_profiles_import\Form\AZPersonProfilesImportSettingsForm' | ||
requirements: | ||
_permission: 'administer site configuration' | ||
|
||
az_person_profiles_import.form: | ||
path: '/admin/content/profiles/import' | ||
defaults: | ||
_title: 'Import Profiles' | ||
_form: 'Drupal\az_person_profiles_import\Form\AZPersonProfilesImportForm' | ||
requirements: | ||
_permission: 'create az_person content' |
8 changes: 8 additions & 0 deletions
8
modules/custom/az_person/az_person_profiles_import/az_person_profiles_import.services.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
services: | ||
_defaults: | ||
autoconfigure: true | ||
az_person_profiles_import_subscriber: | ||
class: Drupal\az_person_profiles_import\EventSubscriber\AZPersonProfilesImportEventSubscriber | ||
arguments: | ||
- '@messenger' | ||
- '@entity_type.manager' |
2 changes: 2 additions & 0 deletions
2
...az_person/az_person_profiles_import/config/install/az_person_profiles_import.settings.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
endpoint: 'https://profiles-api.arizona.edu' | ||
apikey: '' |
11 changes: 11 additions & 0 deletions
11
...om/az_person/az_person_profiles_import/config/schema/az_person_profiles_import.schema.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Schema for the configuration files of the Quickstart Person Profiles Import module. | ||
az_person_profiles_import.settings: | ||
type: config_object | ||
label: 'Quickstart Person Profiles Import settings' | ||
mapping: | ||
endpoint: | ||
type: string | ||
label: 'Profiles Endpoint' | ||
apikey: | ||
type: string | ||
label: 'API Key' |
112 changes: 112 additions & 0 deletions
112
modules/custom/az_person/az_person_profiles_import/migrations/az_person_profiles_import.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
id: az_person_profiles_import | ||
label: Profiles Integration | ||
migration_tags: | ||
- Profiles Integration | ||
source: | ||
plugin: url | ||
data_fetcher_plugin: az_profiles_api_fetcher | ||
data_parser_plugin: az_person_profiles_import_json | ||
urls: [] | ||
item_selector: / | ||
ids: | ||
netid: | ||
type: string | ||
constants: | ||
NAME: 'name' | ||
|
||
fields: | ||
- | ||
name: netid | ||
selector: 'Person/netid' | ||
- | ||
name: surname | ||
selector: 'Person/surname' | ||
- | ||
name: givenname | ||
selector: 'Person/givenname' | ||
- | ||
name: email | ||
selector: 'Person/email' | ||
- | ||
name: biography | ||
selector: 'Bio/desc' | ||
- | ||
name: titles | ||
selector: 'Titles' | ||
- | ||
name: phone | ||
selector: 'Person/phone' | ||
- | ||
name: office | ||
selector: 'Person/office' | ||
- | ||
name: degrees | ||
selector: 'Degrees' | ||
|
||
process: | ||
nid: | ||
- | ||
plugin: entity_lookup | ||
entity_type: node | ||
bundle_key: type | ||
bundle: az_person | ||
value_key: field_az_netid | ||
source: netid | ||
- | ||
plugin: skip_on_empty | ||
method: process | ||
type: | ||
plugin: default_value | ||
default_value: az_person | ||
field_az_fname: givenname | ||
field_az_lname: surname | ||
field_az_netid: netid | ||
field_az_email: | ||
- | ||
plugin: skip_on_empty | ||
method: row | ||
source: email | ||
message: 'is unavailable in the profiles API' | ||
- | ||
plugin: get | ||
field_az_body/value: biography | ||
field_az_body/format: | ||
plugin: default_value | ||
default_value: az_standard | ||
field_az_titles: | ||
plugin: sub_process | ||
source: titles | ||
process: | ||
value: desc | ||
field_az_degrees: | ||
plugin: az_person_degrees | ||
source: degrees | ||
field_az_phones: | ||
plugin: sub_process | ||
source: phone | ||
process: | ||
value: number | ||
field_az_address: | ||
- | ||
plugin: sub_process | ||
source: office | ||
process: | ||
0: | ||
plugin: concat | ||
source: | ||
- building_name | ||
- room_nbr | ||
delimiter: ' ' | ||
- | ||
plugin: flatten | ||
- | ||
plugin: concat | ||
delimiter: "\n" | ||
destination: | ||
plugin: entity:node | ||
bundle: az_person | ||
|
||
dependencies: | ||
enforced: | ||
module: | ||
- az_person |
Oops, something went wrong.