I think it would be useful for deployment

Comments

eric.chenchao’s picture

This is an awesome idea. Actually, we are using this in our very dependent code in our custom module. It will be great to become generic and view integrated function.

dww’s picture

It's hard to make a generic API function for this because you need to do an EntityFieldQuery but you need to know the field name. The API as such would just be a thin wrapper around something that looks like this:

  $query = new EntityFieldQuery();
  $result = $query->entityCondition('entity_type', 'node', '=')
    ->fieldCondition('field_machine_name', 'value', $machinename, '=')
    ->execute();
  return $result['node'];

more or less. You'd have to pass in the 'field_machine_name' and 'node' parts to the API so that it knew what entity type and field name to use. Almost seems like more trouble than it's worth to make this an API function.

c-logemann’s picture

Status: Active » Postponed

Postponed until somebody provides a good solution.

c-logemann’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
c-logemann’s picture

Just switch back to 7.x-1.x-dev branch because of new maintaining strategy.

c-logemann’s picture

Version: 7.x-2.x-dev » 7.x-1.x-dev
danrod’s picture

Issue summary: View changes

I'm closing this issue too given that Drupal 7 is no longer supported, if anyone needs this included in a potential D7 release, please contact me.

danrod’s picture

Status: Postponed » Closed (outdated)

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

c-logemann’s picture

Since D8+ it's so easy to realize just with the EntityTypeManager (etm). So it doesn't make sense to build an API inside this module.
Incomplete example, just to show a starting point:

$storage = \Drupal::entityTypeManager()->getStorage($entity_type);
$entities_array = $storage->loadByProperties(['field_name' => $machine_name_value) ?? [];