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


PHP EntityFieldQuery::addMetaData方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: addExtraInfoToQuery

 /**
  * Adds query tags and metadata to the EntityFieldQuery.
  *
  * @param \EntityFieldQuery|\SelectQuery $query
  *   The query to enhance.
  */
 protected function addExtraInfoToQuery($query)
 {
     // Add a generic tags to the query.
     $query->addTag('restful');
     $query->addMetaData('account', $this->getAccount());
 }
开发者ID:jhoffman-tm,项目名称:waldorf-deployment,代码行数:12,代码来源:DataProvider.php

示例6: buildEntityFieldQuery

 /**
  * Build an EntityFieldQuery to get referencable entities.
  */
 protected function buildEntityFieldQuery($match = NULL, $match_operator = 'CONTAINS')
 {
     $query = new EntityFieldQuery();
     global $user;
     $query->entityCondition('entity_type', 'commerce_store');
     if (!user_access('add products to any store')) {
         $query->fieldCondition('cmp_m_store', 'target_id', $user->uid);
     }
     if (isset($match)) {
         $entity_info = entity_get_info('commerce_store');
         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);
     return $query;
 }
开发者ID:rareimagery,项目名称:budhoundapp,代码行数:24,代码来源:EntityReference_SelectionHandler_Commerce_Store.class.php

示例7: rebuildBatchFetch

 /**
  * {@inheritdoc}
  */
 public function rebuildBatchFetch($entity, &$context)
 {
     if (!isset($context['sandbox']['info'])) {
         $context['sandbox']['info'] = xmlsitemap_get_link_info($entity);
         $context['sandbox']['progress'] = 0;
         $context['sandbox']['last_id'] = 0;
     }
     $info = $context['sandbox']['info'];
     $query = new EntityFieldQuery();
     $query->entityCondition('entity_type', $entity);
     $query->entityCondition('entity_id', $context['sandbox']['last_id'], '>');
     $query->addTag('xmlsitemap_link_bundle_access');
     $query->addTag('xmlsitemap_rebuild');
     $query->addMetaData('entity', $entity);
     $query->addMetaData('entity_info', $info);
     if (!isset($context['sandbox']['max'])) {
         $count_query = clone $query;
         $count_query->count();
         $context['sandbox']['max'] = $count_query->execute();
         if (!$context['sandbox']['max']) {
             // If there are no items to process, skip everything else.
             return;
         }
     }
     // PostgreSQL cannot have the ORDERED BY in the count query.
     $query->entityOrderBy('entity_id');
     // get batch limit
     $limit = $this->config > get('batch_limit');
     $query->range(0, $limit);
     $result = $query->execute();
     $ids = array_keys($result[$entity]);
     $info['xmlsitemap']['process callback']($ids);
     $context['sandbox']['last_id'] = end($ids);
     $context['sandbox']['progress'] += count($ids);
     $context['message'] = t('Now processing %entity @last_id (@progress of @count).', array('%entity' => $entity, '@last_id' => $context['sandbox']['last_id'], '@progress' => $context['sandbox']['progress'], '@count' => $context['sandbox']['max']));
     if ($context['sandbox']['progress'] >= $context['sandbox']['max']) {
         $context['finished'] = 1;
     } else {
         $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
     }
 }
开发者ID:jeroenos,项目名称:jeroenos_d8.mypressonline.com,代码行数:44,代码来源:XmlSitemapGenerator.php


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