undefined $bundle_config errors in watchdog #5

Open
opened 4 weeks ago by rlefaive · 1 comments
rlefaive commented 4 weeks ago
Owner

pointing to this line: https://git.library.upei.ca/Code/metadata_profiles/src/branch/main/src/Controller/MetadataProfileController.php#L1202

Can we update it to do an if (isset($bundle_config)) first?

Alternately (/additionally), we could expand the above lines to include media. I am guessing this is failing on field_representative_image.

pointing to this line: https://git.library.upei.ca/Code/metadata_profiles/src/branch/main/src/Controller/MetadataProfileController.php#L1202 Can we update it to do an if `(isset($bundle_config))` first? Alternately (/additionally), we could expand the above lines to include media. I am guessing this is failing on field_representative_image.
Owner

I added a default earlier in the method. Once we have all the handlers we want I'm thinking something like

$bundle_storage = match ($handler) {
  'default:node' => 'node_type',
  'default:media' => 'media_type',
  'default:taxonomy_term' => 'taxonomy_vocabulary',
  'default:paragraph' => 'paragraphs_type',
  default => NULL,
};

then a single

  $bundle_config = $this->entityTypeManager()
    ->getStorage($bundle_storage)
    ->load($bundle);

does the trick.
(I've been looking for an excuse to use match for a while now.)

I added a default earlier in the method. Once we have all the handlers we want I'm thinking something like ``` $bundle_storage = match ($handler) { 'default:node' => 'node_type', 'default:media' => 'media_type', 'default:taxonomy_term' => 'taxonomy_vocabulary', 'default:paragraph' => 'paragraphs_type', default => NULL, }; ``` then a single ``` $bundle_config = $this->entityTypeManager() ->getStorage($bundle_storage) ->load($bundle); ``` does the trick. (I've been looking for an excuse to use match for a while now.)
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.