Add a loadbyMail and loadByUser to be available to entityTypeManager

Created on 11 August 2023, over 1 year ago

Problem/Motivation

If you want to use dependency injection within your custom code to use a Contact's custom methods (like loadByUser and loadByEmail), you can't do it. That's because these methods are located on the Contact class instead of the Contact storage class.

Steps to reproduce

Funning:

\Drupal::entityTypeManager()->getStorage('redhen_contact');

Loads this class:

Drupal\Core\Entity\Sql\SqlContentEntityStorage

which doesn't know about the loadBy commands.

There may be other methods missing in the Interface.

Proposed resolution

The Profile module implements their own custom Storage in order to accomplish this, which we could copy:

https://git.drupalcode.org/project/profile/-/blob/8.x-1.x/src/ProfileSto...

Remaining tasks

Implement the changes in ProfileStorage

User interface changes

- none -

API changes

- none -

Data model changes

- none (I think) -

πŸ› Bug report
Status

Active

Version

2.0

Component

Shared

Created by

πŸ‡ΊπŸ‡ΈUnited States mariacha1

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024