123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
- class TripalFieldQuery extends EntityFieldQuery {
- protected $field_storage = array();
- public function execute() {
-
- drupal_alter('entity_query', $this);
- $this->altered = TRUE;
-
- $this->initializePager();
-
-
- if ($this->fields) {
-
-
- foreach ($this->fields as $field) {
- $this->field_storage[$field['storage']['type']] = $field['storage']['module'];
- }
-
- $results = array();
-
- foreach ($this->field_storage as $storage_type => $storage_module) {
-
- $callback = $this->queryStorageCallback($storage_module);
- $st_results = call_user_func($callback, $this);
-
-
- if (count($results) == 0) {
- $results = $st_results;
- }
-
-
- else {
- $intersection = array(
- 'TripalEntity' => array(),
- );
- foreach ($st_results['TripalEntity'] as $entity_id => $stub) {
- if (array_key_exists($entity_id, $results['TripalEntity'])) {
- $intersection['TripalEntity'][$entity_id] = $stub;
- }
- }
- $results = $intersection;
- }
- }
- }
-
-
- else {
- $results = call_user_func($this->queryCallback(), $this);
- }
- if ($results and $this->count) {
- return $results;
- }
- else {
- return $results;
- }
- }
-
- public function queryStorageCallback($storage) {
-
-
- if (function_exists($this->executeCallback)) {
- return $this->executeCallback;
- }
-
-
- if (empty($this->fields)) {
- return array($this, 'propertyQuery');
- }
- if ($storage) {
-
- return $storage . '_field_storage_query';
- }
- else {
- throw new EntityFieldQueryException(t("Field storage engine not found."));
- }
- }
- }
|