Consider refactoring FillPdfContextManager::loadEntities()

Created on 17 April 2019, about 6 years ago
Updated 30 May 2025, about 1 month ago

This issue emerged from #3048947: Refactor HandlePdfController::populatePdf() .

FillPdfContextManager::loadEntities() currently returns a multidimensional array of entities, keyed by entity_id and grouped by entity_type. While in theory this is the proper way, it unnecessaryíly adds quite some complexity to all places where it is called.

We should probably turn this into a simple array, either keyed by a composite string of "{entity_type}:{entity_id}" or just as a plain non-associative list with the numeric keys representing the order of precedence, possibly already reversed.

We'd thereby avoid one more foreach() layer and an array_reverse() everywhere it is called and get typehinting for free (currently a @var comment needed). Apart from BC considerations, there should be no real downsides, as both entity type and ID are available in the entity itself.

📌 Task
Status

Closed: outdated

Version

4.0

Component

Code

Created by

Pancho UTC+2 🇪🇺 EU

Live updates comments and jobs are added and updated live.
  • API clean-up

    Refactors an existing API or subsystem for consistency, performance, modularization, flexibility, third-party integration, etc. May imply an API change. Frequently used during the Code Slush phase of the release cycle.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    I am closing this issue, which was created for a project version compatible with a Drupal release no longer supported. Feel free to re-open the issue, if it is still relevant for a project version compatible with a supported Drupal release.

Production build 0.71.5 2024