Improve Connection with multiple bundles chosen

Created on 31 August 2022, over 2 years ago
Updated 7 June 2023, over 1 year ago

If you have a created a Connection that has multiple bundles chosen, like this:

The probability is very high that you never get a match here:


  public function getEndpointEntityTypes($entity_type_id, $bundle) {
    // If the current entity type is in a connection endpoint.
    if ($this->getEndpointEntityTypeId(1) === $entity_type_id || $this->getEndpointEntityTypeId(2) === $entity_type_id) {
      // If the current entity bundle is in a connection endpoint bundle.
      $endBundles1 = $this->getEndpointBundles(1);
      $bundle1 = reset($endBundles1);
      $endBundles2 = $this->getEndpointBundles(2);
      $bundle2 = reset($endBundles2);
      if ($bundle1 === $bundle || $bundle2 === $bundle) {
        return $entity_type_id;
      }
    }
    return FALSE;
  }

}

Resulting in a error when you try to add a connection (/redhen/contact/2/connection/add):

"You have not created any Connection types yet. to add a new type."

Proposed resolution

Or you don't allow multiple bundles to be selected, or you improve the logic in \Drupal\redhen_connection\Entity\ConnectionType::getEndpointEntityTypes

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Shared

Created by

πŸ‡΅πŸ‡ΉPortugal introfini

Live updates comments and jobs are added and updated live.
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.

Production build 0.71.5 2024