当前位置: 首页>>代码示例>>PHP>>正文


PHP EntityFieldQuery::propertyCondition方法代码示例

本文整理汇总了PHP中EntityFieldQuery::propertyCondition方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityFieldQuery::propertyCondition方法的具体用法?PHP EntityFieldQuery::propertyCondition怎么用?PHP EntityFieldQuery::propertyCondition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EntityFieldQuery的用法示例。


在下文中一共展示了EntityFieldQuery::propertyCondition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getEntityID

 /**
  * Get the entity ID.
  *
  * @param $entity_type
  *   'node', 'user', etc.
  * @param $title
  *   Title of the entity.
  * @param $bundle
  *   Optional; The bundle of the entity.
  *
  * @return mixed
  *   The entity ID (in case of $return).
  */
 public static function getEntityID($entity_type, $title, $bundle = NULL)
 {
     $query = new EntityFieldQuery();
     $query->entityCondition('entity_type', $entity_type);
     if ($entity_type == 'node') {
         $query->propertyCondition('title', $title);
     } else {
         if ($entity_type == 'file') {
             $query->propertyCondition('filename', $title);
         }
     }
     if ($bundle) {
         $query->entityCondition('bundle', $bundle);
     }
     $result = $query->execute();
     // Currently only support file and node.
     if ($entity_type == 'node') {
         $identifier = 'nid';
     } else {
         if ($entity_type == 'file') {
             $identifier = 'fid';
         }
     }
     if (empty($result[$entity_type])) {
         return NULL;
     }
     return reset($result[$entity_type])->{$identifier};
 }
开发者ID:aleph-n,项目名称:opencholar,代码行数:41,代码来源:FeatureHelper.php

示例2: actionList

 public function actionList()
 {
     $sels = new Sels();
     $easyNewsall = array();
     $query = new EntityFieldQuery();
     $query->entityCondition('entity_type', 'node')->entityCondition('bundle', 'clue')->propertyOrderBy('nid', 'DESC')->propertyCondition('status', 1)->range(0, 20);
     if (isset($_POST['lastnewsid'])) {
         $query->propertyCondition('nid', $_POST['lastnewsid'], '<');
     }
     $result = $query->execute();
     if (isset($result['node'])) {
         $news_items_nids = array_keys($result['node']);
         $news = node_load_multiple($news_items_nids);
     }
     foreach ($news as $new) {
         $easyNews['id'] = $new->nid;
         $easyNews['title'] = $new->title;
         $easyNews['img1'] = str_replace("public://", BigImg, $new->field_tux['und'][0]['uri']);
         array_push($easyNewsall, $easyNews);
     }
     $sels->articles = $easyNewsall;
     $jsonObj = CJSON::encode($sels);
     /* if(isset($key))
     	   $cache->set($key,$jsonObj,0,new CDbCacheDependency('select max(id) from tbl_dblogs'));
     	  */
     echo $jsonObj;
 }
开发者ID:dingruoting,项目名称:tydaily,代码行数:27,代码来源:ClueController.php

示例3: buildEntityFieldQuery

 /**
  * Build an EntityFieldQuery to get referencable entities.
  * Almost the same as EntityReference_SelectionHandler_Generic::buildEntityFieldQuery,
  * but the bundles are dynamic.
  */
 protected function buildEntityFieldQuery($match = NULL, $match_operator = 'CONTAINS')
 {
     $query = new EntityFieldQuery();
     $query->entityCondition('entity_type', $this->field['settings']['target_type']);
     $node_types = project_node_types_by_behavior($this->field['settings']['handler_settings']['behavior']);
     if (!empty($node_types)) {
         $query->entityCondition('bundle', $node_types, 'IN');
     }
     if (isset($match)) {
         $entity_info = entity_get_info($this->field['settings']['target_type']);
         if (isset($entity_info['entity keys']['label'])) {
             $query->propertyCondition($entity_info['entity keys']['label'], $match, $match_operator);
         }
     }
     // Add a generic entity access tag to the query.
     $query->addTag($this->field['settings']['target_type'] . '_access');
     $query->addTag('entityreference');
     $query->addMetaData('field', $this->field);
     $query->addMetaData('entityreference_selection_handler', $this);
     // Add the sort option.
     if (!empty($this->field['settings']['handler_settings']['sort'])) {
         $sort_settings = $this->field['settings']['handler_settings']['sort'];
         if ($sort_settings['type'] == 'property') {
             $query->propertyOrderBy($sort_settings['property'], $sort_settings['direction']);
         } elseif ($sort_settings['type'] == 'field') {
             list($field, $column) = explode(':', $sort_settings['field'], 2);
             $query->fieldOrderBy($field, $column, $sort_settings['direction']);
         }
     }
     return $query;
 }
开发者ID:washim,项目名称:techsupport,代码行数:36,代码来源:Project_SelectionHandler_ProjectBehavior.class.php

示例4: getBillingCycle

 /**
  * Returns the user's billing cycle with the provided start time.
  *
  * If an existing billing cycle matches the expected start and end, it will
  * be returned. Otherwise, a new one will be created.
  *
  * @param $uid
  *   The uid of the user.
  * @param $start
  *   The unix timestamp when the billing cycle needs to start.
  * @param $save
  *   Whether to save the created billing cycle entity.
  *   Passing FALSE allows an unsaved billing cycle entity to be returned
  *   for estimation purposes.
  *
  * @return
  *   A cl_billing_cycle entity.
  */
 public function getBillingCycle($uid, $start = REQUEST_TIME, $save = TRUE)
 {
     // Make the billing cycle exactly 30 days long, so that it can be divided
     // predictably for prorating.
     // The 1 is substracted to make sure that the billing cycle ends 1s before
     // the next one starts
     $end = $start + 2592000 - 1;
     // Try to find an existing billing cycle matching our parameters.
     $query = new EntityFieldQuery();
     $query->entityCondition('entity_type', 'cl_billing_cycle')->entityCondition('bundle', $this->name)->propertyCondition('status', 1)->propertyCondition('uid', $uid);
     if ($start != REQUEST_TIME) {
         // In case of a custom start, make sure to match the exact billing cycle.
         // Ensures that new orders get the previous billing cycle created at the
         // start of testing, while getNextBillingCycle returns the expected result.
         $query->propertyCondition('start', $start);
     }
     $result = $query->execute();
     if ($result) {
         $billing_cycle_id = key($result['cl_billing_cycle']);
         $billing_cycle = entity_load_single('cl_billing_cycle', $billing_cycle_id);
     } else {
         // No existing billing cycle found. Create a new one.
         $billing_cycle = entity_create('cl_billing_cycle', array('type' => $this->name));
         $billing_cycle->uid = $uid;
         $billing_cycle->start = $start;
         $billing_cycle->end = $end;
         $billing_cycle->status = 1;
         if ($save) {
             $billing_cycle->save();
         }
     }
     return $billing_cycle;
 }
开发者ID:ivanvincent,项目名称:imsv_fe,代码行数:51,代码来源:CommerceLicenseBillingCycleTypeTest.class.php

示例5: view

 /**
  * Displays the bean.
  */
 public function view($bean, $content, $view_mode = 'default', $langcode = NULL)
 {
     // Retrieve the terms from the loaded entity.
     $active_entity = bean_tax_active_entity_array();
     // Check for cached content on this block.
     $cache_name = 'bean_tax:listing:' . $bean->delta . ':' . $active_entity['type'] . ':' . $active_entity['ids'][0];
     if ($cache = cache_get($cache_name)) {
         $content = $cache->data;
     } else {
         // We need to make sure that the bean is configured correctly.
         if ($active_entity['type'] != 'bean' && !empty($bean->filters['vocabulary']) && (isset($active_entity['terms']) && count($active_entity['terms']))) {
             // Reformat vocabulary list from machine names to vocabulary vids.
             $vids = array();
             foreach ($bean->filters['vocabulary'] as $vm) {
                 $query = new EntityFieldQuery();
                 $result = $query->entityCondition('entity_type', 'taxonomy_vocabulary');
                 $query->propertyCondition('machine_name', $vm);
                 global $language;
                 if ($language->language != NULL && db_field_exists('taxonomy_vocabulary', 'language')) {
                     $query->propertyCondition('language', $language->language);
                 }
                 $result = $query->execute();
                 foreach ($result['taxonomy_vocabulary'] as $vocabulary) {
                     $vids[$vocabulary->vid] = $vocabulary->vid;
                 }
             }
             $i = 0;
             $content['terms'] = array();
             // Parse terms from correct vocabularies, limit list to X results.
             foreach ($active_entity['terms'] as $term) {
                 $term = entity_load_single('taxonomy_term', $term->tid);
                 if (in_array($term->vid, $vids) && $i < $bean->settings['records_shown']) {
                     $content['terms'][$term->tid] = entity_view('taxonomy_term', array($term->tid => $term), $bean->settings['term_view_mode']);
                     $i++;
                 }
             }
             cache_set($cache_name, $content, 'cache', time() + 60 * $bean->settings['cache_duration']);
         } elseif (isset($active_entity['type']) && $active_entity['type'] == 'bean' && $bean->bid === $active_entity['object']->bid) {
             $content['#markup'] = '';
         } elseif ($bean->settings['hide_empty'] || !$active_entity['object']) {
             return;
         } else {
             $content['#markup'] = t('No terms.');
         }
     }
     return $content;
 }
开发者ID:stevebresnick,项目名称:iomedia_stp_d7_core,代码行数:50,代码来源:TaxListingBean.class.php

示例6: scanReports

    private function scanReports () {
        $this->affected = array();

        $query = new \EntityFieldQuery();
        $query->entityCondition('entity_type', 'node');
        $query->propertyCondition('type', NODE_TYPE_REPORT);
        $query->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');
        $result = $query->execute();
        $reportNids = isset($result['node']) ? array_keys($result['node']) : NULL;
        $reportNodes = node_load_multiple($reportNids);
        
        foreach ( $reportNodes as $node ) {
            $datasetName = get_node_field_value($node,'field_report_dataset_sysnames');
            if ( empty($datasetName) ) {
                $patient = array(
                    'info' => array(
                        'reportNodeId' => $node->nid,
                        'reportTitle' => $node->title,
                        'published' => $node->status,
                        'type' => $node->type,
                        'datasetName' => $datasetName
                    ),
                    'notes' => 'Dataset field is empty.'
                );

                $this->attachTreatment($patient);
                $this->affected[] = $patient;
                continue;
            }

            // lookup dataset
            $datasourceQuery = new \EntityFieldQuery();
            $datasourceQuery->entityCondition('entity_type', 'node');
            $datasourceQuery->propertyCondition('type', NODE_TYPE_DATASET);
            $datasourceQuery->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');
            $datasourceQuery->fieldCondition('field_dataset_sysname', 'value', $datasetName);
            $datasourceQuery->fieldCondition('field_dataset_datasource', 'value', get_node_field_value($node,'field_report_datasource'));
            $datasourceEntities = $datasourceQuery->execute();
            $datasource_nids = isset($datasourceEntities['node']) ? array_keys($datasourceEntities['node']) : NULL;

            if (count($datasource_nids) != 1) {
                $patient = array(
                    'info' => array(
                        'reportNodeId' => $node->nid,
                        'reportTitle' => $node->title,
                        'published' => $node->status,
                        'type' => $node->type,
                        'datasetName' => $datasetName
                    ),
                    'notes' => 'Dataset does not exist.'
                );

                $this->attachTreatment($patient);
                $this->affected[] = $patient;
                continue;
            }
        }
    }
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:58,代码来源:MissingDatasetSymptom.php

示例7: scanReportConfigs

    private function scanReportConfigs () {
        $this->affected = array();

        $query = new \EntityFieldQuery();
        $query->entityCondition('entity_type', 'node');
        $query->propertyCondition('type', NODE_TYPE_REPORT);
        $query->propertyCondition('status', NODE_PUBLISHED);
        $query->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');
        $result = $query->execute();
        $reportNids = isset($result['node']) ? array_keys($result['node']) : NULL;
        $reportNodes = node_load_multiple($reportNids);
        
        foreach ( $reportNodes as $node ) {

            \LogHelper::log_info(t('Inspecting report @nid', array('@nid' => $node->nid)));

            $reportConfigText = get_node_field_value($node, 'field_report_conf', 0, 'value', FALSE);
            $reportConfig = isset($reportConfigText) ? json_decode($reportConfigText) : NULL;
            if (!isset($reportConfig)) {
                \LogHelper::log_info('Report configuration is EMPTY');
                continue;
            }

            // loop through filters
            if (!empty($reportConfig->model->filters)) {
                foreach ($reportConfig->model->filters as $key => $value) {
                    $result = $this->detectInvalidFilter($value);
                    if ($result) {
                        $patient = array(
                            'info' => array(
                                'reportNodeId' => $node->nid,
                                'reportTitle' => $node->title,
                                'filter' => $value,
                                'published' => $node->status,
                                'configPath' => 'model/filters'
                            ),
                            'notes' => $result
                        );
                        $this->attachTreatment($patient);
                        $this->affected[] = $patient;
                    }
                }
            }
        }
    }
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:45,代码来源:InvalidHiddenFilterSymptom.php

示例8: Query

 /**
  * @inheritdoc
  */
 public static function Query($id = NULL)
 {
     $query = new EntityFieldQuery();
     $query->entityCondition('entity_type', 'node')->propertyCondition('type', array_keys(vsite_vsite_og_node_type_info()), 'IN');
     if ($id) {
         $query->propertyCondition('nid', $id, '>=');
     }
     return $query;
 }
开发者ID:aleph-n,项目名称:opencholar,代码行数:12,代码来源:update7029.php

示例9: getEntityId

 /**
  * Find entity ID by title.
  */
 private function getEntityId($title, $entity_type = 'node', $bundle = NULL)
 {
     $query = new EntityFieldQuery();
     $query->entityCondition('entity_type', $entity_type);
     if ($bundle) {
         $query->entityCondition('bundle', $bundle);
     }
     $result = $query->propertyCondition('title', $title)->range(0, 1)->execute();
     return !empty($result[$entity_type]) ? key($result[$entity_type]) : FALSE;
 }
开发者ID:roni5,项目名称:todo_restful,代码行数:13,代码来源:FeatureContext.php

示例10: prepare_entity_query_4_node_type

function prepare_entity_query_4_node_type($nodeType, $publishedOnly = PUBLISHED_ONLY) {
    $query = new EntityFieldQuery();
    $query->entityCondition('entity_type', 'node')->propertyCondition('type', $nodeType);
    if ($publishedOnly) {
        $query->propertyCondition('status', NODE_PUBLISHED);
    }
    // Neutralize the 'entity_field_access' query tag added by field_sql_storage_field_storage_query().
    // The result cannot depend on the access grants of the current user.
    $query->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');

    return $query;
}
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:12,代码来源:EntityQueryHelper.php

示例11: scopeExists

 /**
  * Check if the provided scope exists in storage.
  *
  * @param $scope
  *   A space-separated string of scopes.
  * @param $client_id
  *   The requesting client.
  *
  * @return
  *   TRUE if it exists, FALSE otherwise.
  */
 function scopeExists($scope, $client_id = null)
 {
     $scope = explode(' ', trim($scope));
     // Get all scope entities that match the provided scope.
     // Compare the difference.
     $query = new \EntityFieldQuery();
     $query->entityCondition('entity_type', 'oauth2_server_scope');
     $query->propertyCondition('server', $this->server->name);
     $query->propertyCondition('name', $scope);
     $query->addTag('oauth2_server_scope_access');
     $query->addMetaData('oauth2_server', $this->server);
     $results = $query->execute();
     if ($results) {
         $scope_ids = array_keys($results['oauth2_server_scope']);
         $loaded_scopes = entity_load('oauth2_server_scope', $scope_ids);
         $found_scope = array();
         foreach ($loaded_scopes as $loaded_scope) {
             $found_scope[] = $loaded_scope->name;
         }
         return count(array_diff($scope, $found_scope)) == 0;
     }
 }
开发者ID:Sorekk,项目名称:cvillecouncilus,代码行数:33,代码来源:Scope.php

示例12: buildEntityFieldQuery

 /**
  * Build an EntityFieldQuery to get referencable entities.
  */
 public function buildEntityFieldQuery($match = NULL, $match_operator = 'CONTAINS')
 {
     $query = new EntityFieldQuery();
     $query->entityCondition('entity_type', $this->field['settings']['target_type']);
     if (!empty($this->field['settings']['handler_settings']['target_bundles'])) {
         $query->entityCondition('bundle', $this->field['settings']['handler_settings']['target_bundles'], 'IN');
     }
     if (isset($match)) {
         $query->propertyCondition('title', $match, $match_operator);
     }
     // Add an access tag to the query.
     $query->addTag('harmony_access');
     $query->addTag('entityreference');
     $query->addMetaData('field', $this->field);
     $query->addMetaData('entityreference_selection_handler', $this);
     // Adding the 'harmony_thread_access' tag is sadly insufficient for threads: core
     // requires us to also know about the concept of 'published' and
     // 'unpublished'. We need to do that as long as there are no access control
     // modules in use on the site. As long as one access control module is there,
     // it is supposed to handle this check.
     if ((!user_access('bypass harmony forum access control') || !user_access('administer forum content')) && !count(module_implements('harmony_thread_grants'))) {
         $query->propertyCondition('status', HARMONY_PUBLISHED);
         $query->propertyCondition('locked', HARMONY_NOT_LOCKED);
     }
     // Add the sort option.
     if (!empty($this->field['settings']['handler_settings']['sort'])) {
         $sort_settings = $this->field['settings']['handler_settings']['sort'];
         if ($sort_settings['type'] == 'property') {
             $query->propertyOrderBy($sort_settings['property'], $sort_settings['direction']);
         } elseif ($sort_settings['type'] == 'field') {
             list($field, $column) = explode(':', $sort_settings['field'], 2);
             $query->fieldOrderBy($field, $column, $sort_settings['direction']);
         }
     }
     return $query;
 }
开发者ID:rickhumphries,项目名称:elmsln,代码行数:39,代码来源:HarmonyThreadSelectionPlugin.class.php

示例13: findAgent

 function findAgent($json)
 {
     $json_array = drupal_json_decode($json);
     if (!isset($json_array['mbox']) && !isset($json_array['mbox_sha1sum']) && !isset($json_array['openid']) && (!isset($json_array['account']) && !isset($json_array['account']['homePage']) && !isset($json_array['account']['name']))) {
         return 0;
     }
     $query = new EntityFieldQuery();
     $query->entityCondition('entity_type', 'tincan_agent');
     if (isset($json_array['objectType'])) {
         switch ($json_array['objectType']) {
             case 'Agent':
                 $query->propertyCondition('object_type', 'Agent');
                 break;
             case 'Group':
                 $query->propertyCondition('object_type', 'Group');
                 break;
         }
     } else {
         $query->propertyCondition('object_type', 'Agent');
     }
     if (isset($json_array['mbox'])) {
         $query->propertyCondition('mbox', $json_array['mbox']);
     }
     if (isset($json_array['mbox_sha1sum'])) {
         $query->propertyCondition('mbox_sha1sum', $json_array['mbox_sha1sum']);
     }
     if (isset($json_array['openid'])) {
         $query->propertyCondition('openid', $json_array['openid']);
     }
     if (isset($json_array['account'])) {
         if (isset($json_array['account']['homePage'])) {
             $query->propertyCondition('account_home_page', $json_array['account']['homePage']);
         }
         if (isset($json_array['account']['name'])) {
             $query->propertyCondition('account_name', $json_array['account']['name']);
         }
     }
     $result = $query->execute();
     if (isset($result['tincan_agent'])) {
         foreach ($result['tincan_agent'] as $key => $agent) {
             return $key;
         }
     } else {
         return 0;
     }
 }
开发者ID:jackrabbithanna,项目名称:tincan_lrs,代码行数:46,代码来源:State.php

示例14: actionList

 public function actionList()
 {
     if (isset($_POST['uid'])) {
         $tids = user_load($_POST['uid'])->field__danwei;
     } else {
         $tids = array();
         $tids['und'][0]['tid'] = '62';
     }
     //var_dump($tids);
     $sels = new Sels();
     $easyNewsall = array();
     $query = new EntityFieldQuery();
     $query->entityCondition('entity_type', 'node')->entityCondition('bundle', 'sup')->propertyOrderBy('nid', 'DESC')->propertyCondition('status', 1)->range(0, 20);
     if (isset($_POST['lastnewsid'])) {
         $query->propertyCondition('nid', $_POST['lastnewsid'], '<');
     }
     $result = $query->execute();
     if (isset($result['node'])) {
         $news_items_nids = array_keys($result['node']);
         $news = node_load_multiple($news_items_nids);
         foreach ($news as $new) {
             //$power=false;
             //echo '标题:'.$new->title.'<br>';
             //var_dump($new->field__danwei['und']);
             //var_dump($tids['und']);
             foreach ($tids['und'] as $tid) {
                 //echo '$tid:'.$tid.'<br>';
                 if (in_array($tid, $new->field__danwei['und'])) {
                     //$power=true;
                     $easyNews['id'] = $new->nid;
                     $easyNews['title'] = $new->title;
                     $easyNews['img1'] = str_replace("public://", BigImg, $new->field_tux['und'][0]['uri']);
                     $easyNews['label'] = $new->field_biaoqian['und'][0]['value'];
                     array_push($easyNewsall, $easyNews);
                     break;
                 }
             }
         }
     }
     $sels->articles = $easyNewsall;
     $jsonObj = CJSON::encode($sels);
     echo $jsonObj;
 }
开发者ID:dingruoting,项目名称:tydaily,代码行数:43,代码来源:SupController.php

示例15: hook_oauth2_server_default_scope

/**
 * Returns the default scope for the provided server.
 *
 * Invoked by OAuth2_Scope_Drupal.
 * If no hook implementation returns a default scope for the current server,
 * then the one from $server->settings['default_scope'] is used.
 *
 * This hook runs on "authorize" and "token" requests and has access to the
 * client_id in $_GET (for "authorize") or via
 * oauth2_server_get_client_credentials() (for "token").
 * Note that client_id in this case corresponds to $client->client_key.
 *
 * @return
 *   An array of default scopes (their machine names).
 */
function hook_oauth2_server_default_scope($server)
{
    // For the "test" server, grant the user any scope he has access to.
    if ($server->name == 'test') {
        $query = new EntityFieldQuery();
        $query->entityCondition('entity_type', 'oauth2_server_scope');
        $query->propertyCondition('server', $server->name);
        $query->addTag('oauth2_server_scope_access');
        $query->addMetaData('oauth2_server', $server);
        $results = $query->execute();
        if ($results) {
            $scope_ids = array_keys($results['oauth2_server_scope']);
            $scopes = entity_load('oauth2_server_scope', $scope_ids);
            $default_scopes = array();
            foreach ($scopes as $scope) {
                $default_scopes[] = $scope->name;
            }
            return $default_scopes;
        }
    }
}
开发者ID:Sorekk,项目名称:cvillecouncilus,代码行数:36,代码来源:oauth2_server.api.php


注:本文中的EntityFieldQuery::propertyCondition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。