本文整理汇总了PHP中EntityFieldQuery::addTag方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityFieldQuery::addTag方法的具体用法?PHP EntityFieldQuery::addTag怎么用?PHP EntityFieldQuery::addTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityFieldQuery
的用法示例。
在下文中一共展示了EntityFieldQuery::addTag方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: 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;
}
}
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
}
}
}
}
示例6: 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;
}
}
}
示例7: 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;
}
}
示例8: 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());
}
示例9: load
public function load(AbstractMetaModel $metamodel, array $filters = NULL) {
$environment_metamodel = data_controller_get_environment_metamodel();
LogHelper::log_notice(t('Loading Meta Model from GovDashboard Content Types ...'));
$loaderName = $this->getName();
$datasetQuery = new EntityFieldQuery();
$datasetQuery->entityCondition('entity_type', 'node');
$datasetQuery->propertyCondition('type', NODE_TYPE_DATASET);
$datasetQuery->propertyCondition('status', NODE_PUBLISHED);
$datasetQuery->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');
// applying filters. Note that we have custom mapping for filter properties
$datasetFilters = isset($filters['DatasetMetaData']) ? $filters['DatasetMetaData'] : NULL;
if (isset($datasetFilters)) {
foreach ($datasetFilters as $propertyName => $filterValues) {
switch ($propertyName) {
case 'datasourceName':
$selectedDataSourceNames = FALSE;
// checking if any of the data sources are actually data marts
foreach ($filterValues as $datasourceName) {
$datasource = $environment_metamodel->findDataSource($datasourceName);
if (isset($datasource->nid)) {
$selectedDataSourceNames[] = $datasourceName;
}
}
if (isset($selectedDataSourceNames)) {
$datasetQuery->fieldCondition('field_dataset_datasource', 'value', $selectedDataSourceNames);
}
else {
// there is no selected datamarts for this request
return;
}
break;
default:
throw new UnsupportedOperationException(t(
'Unsupported mapping for the property for filtering during dataset loading: %propertyName',
array('%propertyName' => $propertyName)));
}
}
}
$datasetEntities = $datasetQuery->execute();
$dataset_nids = isset($datasetEntities['node']) ? array_keys($datasetEntities['node']) : NULL;
if (!isset($dataset_nids)) {
return;
}
$datasetNodes = node_load_multiple($dataset_nids);
// loading columns for selected datasets
$columnNodes = gd_column_get_columns_4_dataset($dataset_nids, LOAD_ENTITY, INCLUDE_UNPUBLISHED);
// grouping nodes in context of dataset
$datasetsColumnNodes = $this->groupNodesByDataset($columnNodes, 'field_column_dataset');
// preparing dataset & cubes
$processedDatasetCount = 0;
foreach ($datasetNodes as $datasetNode) {
$dataset_nid = $datasetNode->nid;
$datasourceName = get_node_field_value($datasetNode, 'field_dataset_datasource');
$datasource = isset($datasourceName) ? $environment_metamodel->findDataSource($datasourceName) : NULL;
if (!isset($datasource)) {
// the data mart could be unpublished or ...
continue;
}
$datasetColumnNodes = isset($datasetsColumnNodes[$dataset_nid]) ? $datasetsColumnNodes[$dataset_nid] : NULL;
// preparing dataset
$dataset = GD_DatasetMetaModelLoaderHelper::prepareDataset($metamodel, $datasetNode, $datasetColumnNodes, $datasource);
// assigning a loader which created the dataset
$dataset->loaderName = $loaderName;
$processedDatasetCount++;
}
LogHelper::log_info(t('Processed @datasetCount dataset node(s)', array('@datasetCount' => $processedDatasetCount)));
}
示例10: 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
示例11: getAllReferencesTo
public static function getAllReferencesTo($entity_type, array $entity_ids, EntityFieldQuery $query = NULL, $flatten = FALSE)
{
if (!isset($query)) {
$query = new EntityFieldQuery();
$query->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');
}
$references = array();
$fields = FieldHelper::getEntityReferencingFieldsByType($entity_type);
foreach ($fields as $field_name => $columns) {
foreach (array_keys($columns) as $column) {
$field_query = clone $query;
$field_query->fieldCondition($field_name, $column, $entity_ids);
if ($results = $field_query->execute()) {
if ($flatten) {
$references = drupal_array_merge_deep($references, $results);
} else {
$references[$field_name . ':' . $column] = $results;
}
}
}
}
return $references;
}
示例12: 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'];
}
}
示例13: attachTreatment
private function attachTreatment ( &$diagnosis ) {
$diagnosis['treatments'] = array();
$diagnosis['treatments'][] = 'ReportConfigRemoveColumnLevel';
$reportNode = node_load($diagnosis['info']['reportNodeId']);
// lookup datasource
$datasourceQuery = new \EntityFieldQuery();
$datasourceQuery->entityCondition('entity_type', 'node');
$datasourceQuery->propertyCondition('type', NODE_TYPE_DATAMART);
$datasourceQuery->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');
$datasourceQuery->fieldCondition('field_datamart_sysname', 'value', get_node_field_value($reportNode, 'field_report_datasource', 0, 'value', FALSE));
$datasourceEntities = $datasourceQuery->execute();
$datasource_nids = isset($datasourceEntities['node']) ? array_keys($datasourceEntities['node']) : NULL;
if (count($datasource_nids) != 1) {
$diagnosis['treatments'][] = 'ReportDelete';
$diagnosis['notes'] .= ' Datasource could not be found.';
} else {
$datamartNode = node_load($datasource_nids[0]);
if ( $datamartNode->status == NODE_PUBLISHED ) {
$diagnosis['notes'] .= ' Datasource is published.';
} else {
$diagnosis['treatments'][] = 'ReportDelete';
$diagnosis['notes'] .= ' Datasource is not published.';
}
}
}
示例14: 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;
}
// check columns
if (!empty($reportConfig->model->columns)) {
foreach ($reportConfig->model->columns as $old) {
if (!isset($old)) {
continue;
}
\LogHelper::log_debug(t('Inspecting report model column @old', array('@old' => $old)));
$result = $this->detectEmptyColumn($old);
if ($result) {
$patient = array(
'info' => array(
'reportNodeId' => $node->nid,
'reportTitle' => $node->title,
'columnName' => $old,
'published' => $node->status,
'configPath' => 'model/columns'
),
'notes' => $result
);
$this->attachTreatment($patient);
$this->affected[] = $patient;
}
}
}
// check column configs
if (!empty($reportConfig->columnConfigs)) {
foreach ($reportConfig->columnConfigs as $key => $value) {
$old = $value->columnId;
\LogHelper::log_debug(t('Inspecting report column config @old', array('@old' => $old)));
$result = $this->detectEmptyColumn($old);
if ($result) {
$patient = array(
'info' => array(
'reportNodeId' => $node->nid,
'reportTitle' => $node->title,
'columnName' => $old,
'published' => $node->status,
'configPath' => 'columnConfigs'
),
'notes' => $result
);
$this->attachTreatment($patient);
$this->affected[] = $patient;
}
}
}
// check column orders
if (!empty($reportConfig->model->columnOrder)) {
foreach ($reportConfig->model->columnOrder as $old) {
if (isset($old)) {
\LogHelper::log_debug(t('Inspecting report column sequence config @old', array('@old' => $old)));
$result = $this->detectEmptyColumn($old);
if ($result) {
$patient = array(
'info' => array(
'reportNodeId' => $node->nid,
'reportTitle' => $node->title,
'columnName' => $old,
'published' => $node->status,
'configPath' => 'model/columnOrder'
),
'notes' => $result
);
$this->attachTreatment($patient);
$this->affected[] = $patient;
}
}
}
}
// check column sorts
if (!empty($reportConfig->model->orderBy)) {
foreach ($reportConfig->model->orderBy as $key => $value) {
$old = $value->column;
\LogHelper::log_debug(t('Inspecting report data sorting column @old', array('@old' => $old)));
//.........这里部分代码省略.........