Problem/Motivation

If I try to access the translation page of a entity type definition I get the following error:
TypeError: Illegal offset type in Drupal\Core\Config\Entity\ConfigEntityStorage->loadOverrideFree() (line 479 of core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php).

If I grasp it correctly this happens because we defined our own parameter loader here:

          $route->setDefault('external_entity_type', $this->entityTypeManager
            ->getStorage('external_entity_type')
            ->load($entity_type_id));

But the config translation handling expects an entity_id to be given which it can load itself.

Steps to reproduce

  1. Configure multiligual site
  2. Enable "External Entities Drupal.org example"
  3. Go to /admin/structure/external-entity-types
  4. Select "Translate" in the dropdown of "Drupal.org module - JSONAPI"

Proposed resolution

Instead of loading the entity right away pass on the entity id but declare it's underlying type:

          $route->setOption('parameters', [
            'external_entity_type' => [
              'type' => 'entity:external_entity_type'
            ]
          ]);

This should allow the parameter resolvers to properly manage the parameter.

Remaining tasks

  1. ✓ Write code
  2. Review
  3. Merge

User interface changes

None

API changes

None

Data model changes

None

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

das-peter created an issue. See original summary.

das-peter’s picture

Assigned: das-peter » Unassigned
Issue summary: View changes
Status: Active » Needs review
guignonv’s picture

Looks fine to me. I just reviewed the code and did not test it yet but I believe it would work.

  • guignonv committed 3dc696ff on 3.0.x authored by das-peter
    Issue #3506171: Illegal offset type in ...\ConfigEntityStorage->...
guignonv’s picture

Status: Needs review » Fixed
colan’s picture

Yes, it works. Just tested it!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.