I'd like to see a live template for EntityFieldQuery... here's a patch :-)

Comments

james.williams’s picture

StatusFileSize
new2.07 KB

Aww, fail... entity_load() needs 2 arguments. Updated patch attached.

sweetchuck’s picture

->propertyCondition('status', 1)
Not each entity type have field "status".

In the $result array the second level keys are the revision IDs, not the entity_id.
$result['node'][42]
42 is a revision ID. {node}.vid.
You can read the NID like this $result['node'][42]->nid

james.williams’s picture

Yes, that's a fair point about the status propertyCondition - but this is just a template for a query, so I would recommend leaving it in there (though perhaps commented out?) as it's too easy to forget that condition.

As for the revision IDs - are you sure? The documentation I've seen for EFQs at http://drupal.org/node/1343708 and http://api.drupal.org/api/drupal/includes%21entity.inc/function/EntityFi... both suggest that you can just pass array_keys($result[$entity_type$]) as the second parameter to entity_load(). I could totally believe that you're right and the documentation isn't, but can you back this up with any documentation/code?

sweetchuck’s picture

Sorry. You have true. First level key is the entity_id.

sweetchuck’s picture

Status: Active » Needs review
StatusFileSize
new2.16 KB
seanr’s picture

How do I test this? I've applied it to my local copy, but I don't know how to get it into PHPStorm. ./WebIdeConfigManager.php push just skips everything, and I have no idea where PHPStorm puts this stuff to update it manually.

sweetchuck’s picture

@seanr Here is the documentation where the configurations are http://www.jetbrains.com/phpstorm/webhelp/project-and-ide-settings.html

I don't know why the Manager script skip everything. :-|
Update (pull) both repository (WebIdeConfigManager and phpstorm-templates)
Copy here your file/directory structure. Like this:

/.../WebIdeConfigManager/WebIdeConfigManager.php
/.../WebIdeConfigManager/ConfigHome/drupal/fileTemplates/Drupal 7 - mymodule.module.module
/.../WebIdeConfigManager/ConfigHome/drupal/templates/drupal-7.xml
sweetchuck’s picture

EFQ is in the repository because not easy to commit the changes one by one. :-)

If the committed version is not fits for you requirements send new patch.

vlad.dancer’s picture

I've just checked. Perfect, tnx!

vlad.dancer’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community