Problem/Motivation

I would expect to be able to do this:

$variation = ProductVariation::load($vid);
$variation->get('field_registration_types')->createHostEntity();

But I can't, there's no way of getting the host entity directly from the underlying entity.

I have to remember to go the long way around:

$handler = $this->entityTypeManager->getHandler('registration', 'host_entity');
$handler->createHostEntity($variation);

Proposed resolution

Add a createHostEntity() convenience method to RegistrationItemFieldItemlList.

User interface changes

None.

API changes

Method added to RegistrationItemFieldItemlList

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

jonathanshaw created an issue. See original summary.

john.oltman’s picture

Great idea jonathan, were you thinking of providing a patch or is this something I should take.

john.oltman’s picture

Status: Active » Needs review
john.oltman’s picture

Issue summary: View changes
jonathanshaw’s picture

Status: Needs review » Reviewed & tested by the community

Nice

  • john.oltman committed 16d19111 on 3.0.x
    Issue #3378046: Access host entity from RegistrationItemFieldItemlList
    
john.oltman’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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