本文整理汇总了PHP中entity_get_info函数的典型用法代码示例。如果您正苦于以下问题:PHP entity_get_info函数的具体用法?PHP entity_get_info怎么用?PHP entity_get_info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了entity_get_info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: views_data_alter
public function views_data_alter(&$data, $field)
{
$entity_info = entity_get_info($field['settings']['target_type']);
$field_name = $field['field_name'] . '_target_id';
foreach ($data as $table_name => &$table_data) {
if (isset($table_data[$field_name])) {
// This doesn't clash with reference_option_limit module, because that
// never got round to getting support for Views with entityreference
// fields.
$limit_option_pseudo_field_name = $field_name . '_option_limit';
$data[$table_name][$limit_option_pseudo_field_name] = array();
// Copy properties from the original.
foreach (array('group', 'title', 'title short', 'help') as $key) {
$data[$table_name][$limit_option_pseudo_field_name][$key] = $table_data[$field_name][$key];
}
$data[$table_name][$limit_option_pseudo_field_name]['title'] .= ' ' . t('(with restricted options)');
$data[$table_name][$limit_option_pseudo_field_name]['filter'] = array();
// Copy properties from the original filter definition.
foreach (array('field', 'table', 'field_name', 'additional fields') as $key) {
$data[$table_name][$limit_option_pseudo_field_name]['filter'][$key] = $table_data[$field_name]['filter'][$key];
}
$data[$table_name][$limit_option_pseudo_field_name]['filter']['handler'] = 'views_filter_option_limit_handler_filter_options_limit';
}
}
}
开发者ID:shieldsdesignstudio,项目名称:find-a-dr,代码行数:25,代码来源:ViewsFilterOptionLimitBehaviorHandler.class.php
示例2: settingsForm
/**
* Implements EntityReferenceHandler::settingsForm().
*/
public static function settingsForm($field, $instance)
{
$view_settings = empty($field['settings']['handler_settings']['view']) ? '' : $field['settings']['handler_settings']['view'];
$displays = views_get_applicable_views('entityreference display');
// Filter views that list the entity type we want, and group the separate
// displays by view.
$entity_info = entity_get_info($field['settings']['target_type']);
$options = array();
foreach ($displays as $data) {
list($view, $display_id) = $data;
if ($view->base_table == $entity_info['base table']) {
$options[$view->name . ':' . $display_id] = $view->name . ' - ' . $view->display[$display_id]->display_title;
}
}
// The value of the 'view_and_display' select below will need to be split
// into 'view_name' and 'view_display' in the final submitted values, so
// we massage the data at validate time on the wrapping element (not
// ideal).
$form['view']['#element_validate'] = array('entityreference_view_settings_validate');
if ($options) {
$default = !empty($view_settings['view_name']) ? $view_settings['view_name'] . ':' . $view_settings['display_name'] : NULL;
$form['view']['view_and_display'] = array('#type' => 'select', '#title' => t('View used to select the entities'), '#required' => TRUE, '#options' => $options, '#default_value' => $default, '#description' => '<p>' . t('Choose the view and display that select the entities that can be referenced.<br />Only views with a display of type "Entity Reference" are eligible.') . '</p>');
$default = !empty($view_settings['args']) ? implode(', ', $view_settings['args']) : '';
$form['view']['args'] = array('#type' => 'textfield', '#title' => t('View arguments'), '#default_value' => $default, '#required' => FALSE, '#description' => t('Provide a comma separated list of arguments to pass to the view.'));
} else {
$form['view']['no_view_help'] = array('#markup' => '<p>' . t('No eligible views were found. <a href="@create">Create a view</a> with an <em>Entity Reference</em> display, or add such a display to an <a href="@existing">existing view</a>.', array('@create' => url('admin/structure/views/add'), '@existing' => url('admin/structure/views'))) . '</p>');
}
return $form;
}
示例3: form
/**
* Builds extra settings for the block edit form.
*/
public function form($bean, $form, &$form_state)
{
// Here we are defining the form.
$form = array();
// Select objects for the vocabularies that will be used.
$vocabulary = taxonomy_get_vocabularies();
$select_vocabulary_array = array();
foreach ($vocabulary as $item) {
$select_vocabulary_array[$item->machine_name] = $item->name;
}
// Building the basic form for individual 'related' bean configuration.
$form['filters'] = array('#type' => 'fieldset', '#tree' => TRUE, '#title' => t('Filters'));
// Determine related taxonomy term vocabularies.
$form['filters']['vocabulary'] = array('#type' => 'select', '#title' => t('Vocabulary'), '#options' => $select_vocabulary_array, '#default_value' => $bean->filters['vocabulary'], '#required' => TRUE, '#multiple' => TRUE, '#size' => 5);
// Settings fieldset is used for configuring the 'listing' bean output.
$form['settings'] = array('#type' => 'fieldset', '#tree' => TRUE, '#title' => t('Output'));
// Select objects for the taxonomy term view modes that will be used.
$term_view_modes = array();
$entity_info = entity_get_info();
foreach ($entity_info['taxonomy_term']['view modes'] as $key => $value) {
$term_view_modes[$key] = $value['label'];
}
// User select which view mode to use for the term listing inside the bean.
$form['settings']['term_view_mode'] = array('#type' => 'select', '#title' => t('Taxonomy Term View Mode'), '#options' => $term_view_modes, '#default_value' => $bean->settings['term_view_mode'], '#required' => TRUE, '#multiple' => FALSE);
// User define a maximum number of terms to be shown.
$form['settings']['records_shown'] = array('#type' => 'textfield', '#title' => t('Records shown'), '#size' => 5, '#default_value' => $bean->settings['records_shown'], '#element_validate' => array('bean_tax_setting_is_numeric'));
$form['settings']['hide_empty'] = array('#type' => 'checkbox', '#title' => t('Do not display block if there are no results.'), '#default_value' => $bean->settings['hide_empty']);
return $form;
}
示例4: getReferencableEntities
/**
* Implements EntityReferenceHandler::getReferencableEntities().
*
* Completely bypass buildEntityFieldQuery(), as we want a regular SQL query
* in order to group and order the timeslots by their containing schedules.
*/
public function getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 25)
{
// We also come here when getting entities for the default value widget.
// There's no way to check this is what we're doing so just return nothing
// if the settings are missing.
if (empty($this->field['settings']['handler_settings']['behaviors']['session_timeslot']['status'])) {
return array();
}
// Figure out which fields are on schedules and point to timeslots.
$timetable_set = timetable_get_timetable_set($this->field);
$schedule_timeslot_field_name = $timetable_set['schedule']['field_name'];
$schedule_entity_type = $timetable_set['schedule']['entity_type'];
// Get details about the schedule entity type for the query.
$schedule_entity_info = entity_get_info($schedule_entity_type);
$schedule_entity_base_table = $schedule_entity_info['base table'];
$schedule_entity_id_key = $schedule_entity_info['entity keys']['id'];
$schedule_entity_label_key = $schedule_entity_info['entity keys']['label'];
$results = db_query("SELECT\n ts.id,\n time.field_timeslot_time_value AS timeslot_value,\n time.field_timeslot_time_value2 AS timeslot_value2,\n schedule.{$schedule_entity_label_key} AS schedule_label\n FROM {eck_timeslot} ts\n JOIN {field_data_field_timeslot_time} time\n ON ts.id = time.entity_id\n JOIN {field_data_{$schedule_timeslot_field_name}} sts\n ON ts.id = sts.{$schedule_timeslot_field_name}_target_id\n JOIN {{$schedule_entity_base_table}} schedule\n ON sts.entity_id = schedule.{$schedule_entity_id_key}\n ")->fetchAllAssoc('id', PDO::FETCH_ASSOC);
// TODO: get this from the field instance so we match whatever format the
// site builder wants.
$timefield_display_format = array('hour' => 'G', 'minute' => 'i', 'separator' => ':', 'period' => 'none', 'period_separator' => '');
$timeslot_options = array();
foreach ($results as $timeslot_id => $timeslot_data) {
$timeslot_options[$timeslot_id] = check_plain($timeslot_data['schedule_label']) . ': ' . timefield_integer_to_time($timefield_display_format, $timeslot_data['timeslot_value']) . '-' . timefield_integer_to_time($timefield_display_format, $timeslot_data['timeslot_value2']);
}
$options = array('timeslot' => $timeslot_options);
return $options;
}
示例5: 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;
}
示例6: createConsumer
/**
* @see LdapAuthorizationConsumerAbstract::createConsumer
*/
public function createConsumer($consumer_id, $consumer)
{
list($entity_type, $group_name, $rid) = explode(':', $consumer_id);
$group = @ldap_authorization_og2_get_group_from_name($entity_type, $group_name);
if ($group) {
return FALSE;
}
// create og group with name of $group_name of entity type $entity_type
$entity_info = entity_get_info($entity_type);
$new_group_created = FALSE;
/**
*
* @todo
* need to create new entity with title of $group_name here
*
*/
if ($new_group_created === FALSE) {
// if role is not created, remove from array to user object doesn't have it stored as granted
watchdog('user', 'failed to create og group %group_name in ldap_authorizations module', array('%group_name' => $group_name));
return FALSE;
} else {
watchdog('user', 'created og group %group_name in ldap_authorizations module', array('%group_name' => $group_name));
}
return TRUE;
}
示例7: form
/**
* Builds extra settings for the block edit form.
*/
public function form($bean, $form, &$form_state)
{
// Here we are defining the form.
$form = array();
// Settings fieldset is used for configuring the 'related' bean output.
$form['settings'] = array('#type' => 'fieldset', '#tree' => TRUE, '#title' => t('Output'), '#prefix' => '<div id="output-wrapper">', '#suffix' => '</div>');
// Instantiate entity info.
$entity_info = entity_get_info();
// Create a list of entity types that have view modes.
$entity_types = array();
foreach ($entity_info as $key => $value) {
if (!empty($value['view modes'])) {
$entity_types[$key] = $value['label'];
}
}
// Set a cache duration for the block.
$form['settings']['cache_duration'] = array('#type' => 'textfield', '#title' => t('Cache duration (in minutes)'), '#size' => 5, '#default_value' => $bean->settings['cache_duration'], '#required' => TRUE);
// User select how entites are related.
$form['settings']['related'] = array('#type' => 'select', '#title' => t('Related To'), '#options' => array('page' => 'Active Page', 'user' => 'Logged-in User'), '#default_value' => $bean->settings['related'], '#required' => TRUE, '#multiple' => FALSE);
// Determine if auth-user caching is appropriate.
$form['settings']['cache_auth_user'] = array('#type' => 'checkbox', '#title' => t('Cache this block for authenticated users.'), '#description' => t('Warning: This will create a cache record for every authenticated user that views this block.'), '#default_value' => $bean->settings['cache_auth_user'], '#states' => array('visible' => array(':input[name="settings[related]"]' => array('value' => 'user'))));
// Determine if anon-user caching is appropriate.
$form['settings']['cache_anon_user'] = array('#type' => 'checkbox', '#title' => t('Cache this block for anonymous users.'), '#description' => t('This will create a cache record for anonymous users that view this block.'), '#default_value' => $bean->settings['cache_anon_user'], '#states' => array('visible' => array(':input[name="settings[related]"]' => array('value' => 'user'))));
// User select which entity type to use for output.
$form['settings']['entity_type'] = array('#type' => 'select', '#title' => t('Entity Type'), '#options' => $entity_types, '#default_value' => $bean->settings['entity_type'], '#required' => TRUE, '#multiple' => FALSE, '#ajax' => array('callback' => 'bean_tax_entity_type_callback', 'wrapper' => 'output-wrapper', 'method' => 'replace'));
// Check for an ajax update and use new entity_type setting.
if (!isset($form_state['values']['settings']['entity_type'])) {
$entity_type = $bean->settings['entity_type'];
} else {
$entity_type = $form_state['values']['settings']['entity_type'];
}
// User select which view mode to use for the results inside the bean.
$form['settings']['entity_view_mode'] = array('#type' => 'select', '#title' => t('Entity View Mode'), '#options' => bean_tax_get_entity_view_modes($entity_info, $entity_type), '#default_value' => $bean->settings['entity_view_mode'], '#required' => TRUE, '#multiple' => FALSE);
// Determine what entity bundle types to display.
$form['settings']['bundle_types'] = array('#type' => 'select', '#title' => t('Entity Bundles'), '#options' => bean_tax_get_entity_bundles($entity_type), '#default_value' => $bean->settings['bundle_types'], '#required' => TRUE, '#multiple' => TRUE, '#size' => 5);
$form['settings']['hide_empty'] = array('#type' => 'checkbox', '#title' => t('Do not display block if there are no results.'), '#default_value' => $bean->settings['hide_empty']);
$form['settings']['unmatch_add'] = array('#type' => 'checkbox', '#title' => t('Append unrelated entities so there are more results.'), '#default_value' => $bean->settings['unmatch_add']);
// Select objects for the vocabularies that will be used.
$vocabulary = taxonomy_get_vocabularies();
$select_vocabulary_array = array();
foreach ($vocabulary as $item) {
$select_vocabulary_array[$item->machine_name] = $item->name;
}
// Define the filters fieldset.
$form['filters'] = array('#type' => 'fieldset', '#tree' => TRUE, '#title' => t('Filters'));
// User define a maximum number of entities to be shown.
$form['filters']['records_shown'] = array('#type' => 'textfield', '#title' => t('Records shown'), '#size' => 5, '#default_value' => $bean->filters['records_shown'], '#element_validate' => array('bean_tax_setting_is_numeric'));
// User define a maximum number of entities to be shown.
$form['filters']['offset_results'] = array('#type' => 'textfield', '#title' => t('Offset Results'), '#size' => 5, '#default_value' => $bean->filters['offset_results'], '#element_validate' => array('bean_tax_setting_is_numeric'));
// Determine related taxonomy term vocabularies.
$form['filters']['vocabulary'] = array('#type' => 'select', '#title' => t('Vocabularies'), '#options' => $select_vocabulary_array, '#default_value' => $bean->filters['vocabulary'], '#required' => TRUE, '#multiple' => TRUE, '#size' => 5);
// Define a "read more" style link to be shown at the bottom of the bean.
$form['more_link'] = array('#type' => 'fieldset', '#tree' => TRUE, '#title' => t('More link'));
// Link text shown on the 'more link' to be defined by user.
$form['more_link']['text'] = array('#type' => 'textfield', '#title' => t('Link text'), '#default_value' => $bean->more_link['text']);
// Actual URL path for the 'more link' defined by user.
$form['more_link']['path'] = array('#type' => 'textfield', '#title' => t('Link path'), '#default_value' => $bean->more_link['path']);
return $form;
}
示例8: exists
public function exists(NodeInterface $node, Context $context)
{
/* @var $node ViewNode */
$entityType = $node->getEntityType();
$name = $node->getName();
$info = entity_get_info($entityType);
return isset($info) && ('default' === $name || isset($info['view modes'][$name]));
}
示例9: it_can_access_the_database
/**
* @test
*/
public function it_can_access_the_database()
{
if (!function_exists('entity_get_info')) {
$this->fail('Drupal not bootstrapped.');
}
$entityInfo = entity_get_info();
$this->assertCount(6, $entityInfo, 'Entity info returned.');
}
示例10: __construct
/**
* Constructor.
*
* This is private since we want consumers to instantiate via the factory methods.
*
* @param object $node
* A Drupal node.
*/
private function __construct($entity, $entity_type)
{
$this->entity = $entity;
$this->language = $entity->language;
$this->language_targets = Lingotek::getLanguagesWithoutSource($this->language);
$this->entity_type = $entity_type;
$this->info = entity_get_info($this->entity_type);
}
示例11: handlesEntity
public function handlesEntity(Entity $entity)
{
if (!module_exists('xmlsitemap')) {
return false;
}
$info = entity_get_info($entity->type());
return array_key_exists('xmlsitemap', $info) && is_array($info['xmlsitemap']);
}
示例12: getEntityTokenTypes
/**
* Get list of entity info arrays, keyed by the entity's token-like name.
*
* @return array
* List of entity info arrays.
*/
protected function getEntityTokenTypes()
{
$return = array();
foreach (entity_get_info() as $entity_type => $entity_info) {
$entity_type = $entity_type == 'taxonomy_term' ? 'term' : $entity_type;
$return[$entity_type] = $entity_info;
}
return $return;
}
示例13: __construct
public function __construct($name, $info)
{
$this->apiMap = restws_schema_map_get();
$this->propertyInfo = $info['properties'];
$this->resource = $name;
$this->entityType = $this->apiMap[$name]['entity'];
$this->bundleName = $this->apiMap[$name]['bundle'];
$this->entityInfo = entity_get_info($this->apiMap[$name]['entity']);
}
示例14: getDerivativeDefinitions
/**
* {@inheritdoc}
*
* @todo Do we want to limit to content entities? There's a lot in the list.
*/
public function getDerivativeDefinitions(array $base_plugin_definition)
{
foreach (entity_get_info() as $entity_type => $entity_info) {
$this->derivatives[$entity_type] = $base_plugin_definition;
$this->derivatives[$entity_type]['title'] = $entity_info['label'];
$this->derivatives[$entity_type]['entity type'] = $entity_type;
}
$this->sortDerivatives();
return $this->derivatives;
}
示例15: getInstance
/**
* {@inheritdoc}
*/
public static function getInstance($field, $instance = NULL, $entity_type = NULL, $entity = NULL)
{
$target_entity_type = $field['settings']['target_type'];
// Check if the entity type does exist and has a base table.
$entity_info = entity_get_info($target_entity_type);
if (empty($entity_info['base table']) || $target_entity_type != 'user') {
return EntityReference_SelectionHandler_Broken::getInstance($field, $instance);
}
return new ProjectIssue_SelectionHandler_Assigned($field, $instance, $entity_type, $entity);
}