/** * @When /^I attach the file to the field banner$/ */ public function iAttachTheFileToTheField() { $query = new \entityFieldQuery(); $query->entityCondition('entity_type', 'file')->propertyCondition('filename', 'banner6.jpg', 'LIKE')->range(0, 1); $result = $query->execute(); if (!empty($result['file'])) { $fids = array_keys($result['file']); } else { throw new \Exception("File is not found"); } $this->getSession()->executeScript("jQuery(\"input[name='c4m_banner[und][0][fid]']\").val(\"" . $fids[0] . "\");"); }
$query->entityCondition('entity_type', 'node')->propertyCondition('type', 'person'); // Adding node IDs to the query. if ($nids != 0) { $nids = explode(",", $nids); if (!empty($nids)) { $query->propertyCondition('nid', $nids, 'IN'); } } // Adding sites to the query. if ($vsites != 0) { $vsites = explode(",", $vsites); if (!empty($vsites)) { $query->fieldCondition(OG_AUDIENCE_FIELD, 'target_id', $vsites, 'IN'); } } $result = $query->execute(); if (empty($result['node'])) { drush_log(dt('No records were found'), 'error'); return; } $nodes = node_load_multiple(array_keys($result['node'])); // When updating the file field there is a need for flushing the cache. The // variable will notify us later if needed. $flush_cache = FALSE; foreach ($nodes as $node) { $wrapper = entity_metadata_wrapper('node', $node); foreach ($wrapper->field_upload->value() as $value) { // Only private files will be handled during the script. if (strpos($value['uri'], 'public://') === 0) { drush_log(dt('File @name is already public - skipping.', array('@name' => $value['filename'])), 'warning'); continue;