Skip to content

#3595143 Add Typed Relation 'raw' formatter to expose rel_type and target_id#161

Open
kayakr wants to merge 2 commits into
Islandora:2.xfrom
kayakr:2.x
Open

#3595143 Add Typed Relation 'raw' formatter to expose rel_type and target_id#161
kayakr wants to merge 2 commits into
Islandora:2.xfrom
kayakr:2.x

Conversation

@kayakr

@kayakr kayakr commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

#3595143 Add Typed Relation 'raw' formatter to expose rel_type and target_id

GitHub Issue: (link)

  • Other Relevant Links (Google Groups discussion, related pull requests,
    Release pull requests, etc.)

What does this Pull Request do?

Offers new Typed Relation formatter "Typed Relation Formatter (Raw)" that exposes 'raw' rel_type and target_id data, e.g. relators:art=1234 suitable for audit view, or export and import processes.

How should this be tested?

  1. Apply patch/PR
  2. Visit view involving entities with typed relations
  3. Change view field display to sue "Typed Relation Formatter (Raw)"
  4. Observe 'raw' data output in view preview.

Interested parties

@Islandora/committers

@joecorall
joecorall self-requested a review June 10, 2026 17:05
Comment on lines +27 to +29
foreach ($items as $delta => $item) {
$elements[$delta]['#plain_text'] = $item->rel_type . '=' . $item->target_id;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$elements = parent::viewElements($items, $langcode); does entity access checking on the referenced entities. So it's possible an element in $items doesn't exist in $elements and we leak its relator and term ID. Not a big deal, but maybe we should iterate over $elements? Maybe something like

Suggested change
foreach ($items as $delta => $item) {
$elements[$delta]['#plain_text'] = $item->rel_type . '=' . $item->target_id;
}
foreach ($elements as $delta => &$element) {
$item = $items[$delta];
$element['#plain_text'] = $item->rel_type . '=' . $item->target_id;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants