本文整理汇总了PHP中field_info_field函数的典型用法代码示例。如果您正苦于以下问题:PHP field_info_field函数的具体用法?PHP field_info_field怎么用?PHP field_info_field使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了field_info_field函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: settingsForm
/**
* Implements EntityReferenceHandler::settingsForm().
*/
public static function settingsForm($field, $instance)
{
$entity_info = entity_get_info($field['settings']['target_type']);
if (!empty($entity_info['entity keys']['bundle'])) {
$bundles = array();
foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) {
$bundles[$bundle_name] = $bundle_info['label'];
}
$form['target_bundles'] = array('#type' => 'select', '#title' => t('Target bundles'), '#options' => $bundles, '#default_value' => isset($field['settings']['handler_settings']['target_bundles']) ? $field['settings']['handler_settings']['target_bundles'] : array(), '#size' => 6, '#multiple' => TRUE, '#description' => t('The bundles of the entity type that can be referenced. Optional, leave empty for all bundles.'));
} else {
$form['target_bundles'] = array('#type' => 'value', '#value' => array());
}
$form['sort']['type'] = array('#type' => 'radios', '#title' => t('Sort by'), '#options' => array('none' => t("Don't sort"), 'property' => t('A property of the base table of the entity'), 'field' => t('A field attached to this entity')), '#default_value' => isset($field['settings']['handler_settings']['sort']['type']) ? $field['settings']['handler_settings']['sort']['type'] : 'none');
$form['sort']['property'] = array('#type' => 'select', '#title' => t('Sort property'), '#options' => drupal_map_assoc($entity_info['schema_fields_sql']['base table']), '#default_value' => isset($field['settings']['handler_settings']['sort']['property']) ? $field['settings']['handler_settings']['sort']['property'] : '', '#states' => array('visible' => array(':input[name="field[settings][handler_settings][sort][type]"]' => array('value' => 'property'))));
$fields = array();
foreach (field_info_instances($field['settings']['target_type']) as $bundle_name => $bundle_instances) {
foreach ($bundle_instances as $instance_name => $instance_info) {
$field_info = field_info_field($instance_name);
foreach ($field_info['columns'] as $column_name => $column_info) {
$fields[$instance_name . ':' . $column_name] = t('@label (column @column)', array('@label' => $instance_info['label'], '@column' => $column_name));
}
}
}
$form['sort']['field'] = array('#type' => 'select', '#title' => t('Sort field'), '#options' => $fields, '#default_value' => isset($field['settings']['handler_settings']['sort']['type']) ? $field['settings']['handler_settings']['sort']['type'] : '', '#states' => array('visible' => array(':input[name="field[settings][handler_settings][sort][type]"]' => array('value' => 'field'))));
$form['sort']['direction'] = array('#type' => 'select', '#title' => t('Sort direction'), '#options' => array('ASC' => t('Ascending'), 'DESC' => t('Descending')), '#default_value' => isset($field['settings']['handler_settings']['sort']['direction']) ? $field['settings']['handler_settings']['sort']['direction'] : 'ASC', '#states' => array('invisible' => array(':input[name="field[settings][handler_settings][sort][type]"]' => array('value' => 'none'))));
return $form;
}
开发者ID:leloulight,项目名称:drupal-micah-blog,代码行数:30,代码来源:EntityReference_SelectionHandler_Generic.class.php
示例2: publicFields
/**
* Overrides ResourceEntity::publicFields().
*/
public function publicFields()
{
$public_fields = parent::publicFields();
$public_fields['body'] = array('property' => 'body', 'sub_property' => 'value');
// By checking that the field exists, we allow re-using this class on
// different tests, where different fields exist.
if (field_info_field('entity_reference_single')) {
$public_fields['entity_reference_single'] = array('property' => 'entity_reference_single', 'resource' => array('name' => 'test_articles', 'majorVersion' => 1, 'minorVersion' => 2));
}
if (field_info_field('entity_reference_multiple')) {
$public_fields['entity_reference_multiple'] = array('property' => 'entity_reference_multiple', 'resource' => array('name' => 'test_articles', 'majorVersion' => 1, 'minorVersion' => 2));
}
if (field_info_field('integer_single')) {
$public_fields['integer_single'] = array('property' => 'integer_single');
}
if (field_info_field('integer_multiple')) {
$public_fields['integer_multiple'] = array('property' => 'integer_multiple');
}
if (variable_get('restful_test_reference_simple')) {
$public_fields['user'] = array('property' => 'author');
if (variable_get('restful_test_reference_resource')) {
$public_fields['user']['resource'] = array('name' => 'users', 'majorVersion' => 1, 'minorVersion' => 0);
}
}
return $public_fields;
}
示例3: queryLoad
protected function queryLoad($ids)
{
$multifields = multifield_get_fields();
foreach (array_keys($multifields) as $field_name) {
$query = new EntityFieldQuery();
if ($ids) {
$query->fieldCondition($field_name, 'id', $ids, 'IN');
} else {
$query->fieldCondition($field_name, 'id', 0, '>');
}
if ($results = $query->execute()) {
$pseudo_entities = array();
$field = field_info_field($field_name);
foreach ($results as $entity_type => $entities) {
// Simply doing an entity load on the entities with multifield values
// will cause the cacheSet() from multifield_field_load() to get
// invoked.
$entities = entity_load($entity_type, array_keys($entities));
foreach ($entities as $entity) {
if ($items = field_get_items($entity_type, $entity, $field_name)) {
foreach ($items as $item) {
$pseudo_entities[$item['id']] = _multifield_field_item_to_entity($field['type'], $item);
}
}
}
}
$this->cacheSet($pseudo_entities);
}
}
return array_intersect_key($this->entityCache, drupal_map_assoc($ids, $ids));
}
示例4: preprocess
/**
* {@inheritdoc}
*/
public function preprocess($value)
{
// Text field. Check if field has an input format.
$field_info = field_info_field($this->getProperty());
// If there was no bundle that had the field instance, then return NULL.
if (!($instance = field_info_instance($this->getEntityType(), $this->getProperty(), $this->getBundle()))) {
return NULL;
}
$return = NULL;
if ($field_info['cardinality'] == 1) {
// Single value.
if (!$instance['settings']['text_processing']) {
return $value;
}
return array('value' => $value, 'format' => 'filtered_html');
}
// Multiple values.
foreach ($value as $delta => $single_value) {
if (!$instance['settings']['text_processing']) {
$return[$delta] = $single_value;
} else {
$return[$delta] = array('value' => $single_value, 'format' => 'filtered_html');
}
}
return $return;
}
示例5: bunsen_field_attach_view_alter
function bunsen_field_attach_view_alter(&$output, $context)
{
// We proceed only on nodes.
if ($context['entity_type'] != 'node' || $context['view_mode'] != 'full') {
return;
}
$node = $context['entity'];
// Load all instances of the fields for the node.
$instances = _field_invoke_get_instances('node', $node->type, array('default' => TRUE, 'deleted' => FALSE));
foreach ($instances as $field_name => $instance) {
// Only work with fields that we display or that have empty values
$access = !empty($output[$field_name]['#access']) ? $output[$field_name]['#access'] : FALSE;
if ($access || empty($node->{$field_name})) {
// Set content for fields if they are empty.
if (empty($node->{$field_name})) {
$display = field_get_display($instance, 'full', $node);
// Do not add field that is hidden in current display.
if ($display['type'] == 'hidden') {
continue;
}
// Load field settings.
$field = field_info_field($field_name);
// Set output for field.
$output[$field_name] = array('#theme' => 'field', '#title' => $instance['label'], '#label_display' => 'above', '#field_type' => $field['type'], '#field_name' => $field_name, '#bundle' => $node->type, '#object' => $node, '#items' => array(array()), '#entity_type' => 'node', '#weight' => $display['weight'], 0 => array('#markup' => ''));
}
}
}
}
示例6: build
public function build()
{
$type = self::guessType($this->type);
if (!($info = field_info_field($this->name))) {
field_create_field(array('field_name' => $this->name, 'type' => $type, 'module' => ''));
}
}
示例7: accessEditEntityField
/**
* Implements EditEntityFieldAccessCheckInterface::accessEditEntityField().
*/
public function accessEditEntityField($entity_type, $entity, $field_name)
{
$is_extra_field = _quickedit_is_extra_field($entity_type, $field_name);
$entity_access = entity_access('update', $entity_type, $entity);
$field_access = $is_extra_field ? TRUE : field_access('edit', field_info_field($field_name), $entity_type, $entity);
return $entity_access && $field_access;
}
示例8: getFieldDefault
protected function getFieldDefault(NodeInterface $node, $entityType, $bundle, $fieldName, Context $context)
{
/* @var $node ViewNode */
$entityType = $node->getEntityType();
$bundle = $node->getBundle();
$default = array('type' => 'hidden', 'label' => 'hidden', 'settings' => array());
if (!($field = field_info_field($fieldName))) {
// @todo Should we warn? This is surely an extra field.
return $default;
}
if (!($field = field_info_field_types($field['type']))) {
$context->logError("%s: %s field type does not exist", $node->getPath(), $field['types']);
return $default;
}
$formatter = null;
if (!empty($field['default_formatter'])) {
$formatter = $field['default_formatter'];
if (!field_info_formatter_types($formatter)) {
$context->logWarning(sprintf("%s: field %s defines non existing default formatter: %s", $node->getPath(), $fieldName, $formatter));
$formatter = null;
}
}
if ($formatter) {
$default = array('type' => $formatter, 'label' => 'hidden', 'settings' => field_info_formatter_settings($formatter));
}
return $default;
}
示例9: dxray_get_node_type
/**
* Получаем список NODE_TYPE
* modules/node/node.module
* @link https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_node_info/7 description param
* @link https://www.drupal.org/node/1027630 info
*/
function dxray_get_node_type()
{
$GML = new GraphML();
$optN1 = $GML->setOptionsNode()->Fill_setColor('#ccffff')->Label_setFontSize('22')->getOptions();
$aNtypes = node_type_get_types();
foreach ($aNtypes as $oType) {
// 1. Сначала создаем узел NODE_TYPE
$data['attributes'] = array('Base: ' . $oType->base, 'Type: ' . $oType->type, 'Help: ' . PHP_EOL . $oType->help . PHP_EOL, 'Custom: ' . $oType->custom, 'Modified: ' . $oType->modified, 'Locked: ' . $oType->locked, 'Disabled: ' . $oType->disabled, 'Is new: ' . $oType->is_new, 'Has title: ' . $oType->has_title, 'Title label: ' . $oType->title_label, 'Module: ' . $oType->module);
$options['NodeFill']['color'] = '#ccffff';
$ID_bundle = $GML->addNode($oType->name, 'UMLClassNode', $optN1, $data);
dxray_debug_stdout('Добавили bundle номер: ' . $ID_bundle);
// 2. Получаем поля данного контента и строем зависимости
$fields = field_info_instances('node', $oType->type);
foreach ($fields as $field) {
$finfo = field_info_field($field['field_name']);
$data['attributes'] = array('Label: ' . $field['label'], 'Required: ' . $field['required'], 'Module: ' . $finfo['module'], 'Locked: ' . $finfo['locked'], 'Cardinality: ' . $finfo['cardinality'], 'Description: ' . $field['description']);
$dataHTML['attributes'] = array('<html>', 'Label: ' . $field['label'] . '<br>', 'Required: ' . $field['required'] . '<br>', '<b>Module:</b> ' . $finfo['module'] . '<br>', 'Locked: ' . $finfo['locked'] . '<br>', 'Cardinality: ' . $finfo['cardinality'] . '<br>', 'Description: ' . $field['description'] . '<br>', '</html>');
$ID_field = $GML->addNode($field['field_name'], 'UMLClassNode', null, $dataHTML);
dxray_debug_stdout('Добавили field номер: ' . $ID_field);
dxray_debug_stdout("{EDGE} SRC: {$ID_bundle} TARGET: {$ID_field} " . $ID_field);
$GML->addEdge($ID_bundle, $ID_field);
}
}
$file = DXRAY_OUTPATH . '/NodeType-' . date('d-m-Y_H-i-s') . '.graphml';
$GML->createFullGraphML($file);
$dbg = 0;
}
示例10: iShouldHaveAFieldAsTypeHasAWidgetRequiredAndAllowsValue
/**
* @Then /^I should have a "([^"]*)" field as a "([^"]*)" type, has a "([^"]*)" widget, (not required|required), and allows (\d+|(?i)unlimited) value[s]?[.]?$/
*/
public function iShouldHaveAFieldAsTypeHasAWidgetRequiredAndAllowsValue($name, $type, $widget, $required, $cardinality)
{
if (strcasecmp($cardinality, 'unlimited') == 0) {
$cardinality = '-1';
}
$fields = field_info_instances("node", $this->contentType->type);
$wantedField = NULL;
foreach ($fields as $field) {
if ($field['label'] == $name) {
$wantedField = $field;
}
}
assertNotEmpty($wantedField, "Field with the label {$name} doesn't exist");
$fieldInfo = field_info_field($wantedField['field_name']);
$widgetInfo = field_info_widget_types();
$fieldTypeInfo = field_info_field_types();
$wantedField['widget']['info'] = $widgetInfo[$wantedField['widget']['type']];
$wantedField['type'] = $fieldTypeInfo[$fieldInfo['type']];
assertEquals($type, $wantedField['type']['label'], "{$name} doesn't have the type {$type}. Instead it has " . $wantedField['type']['label'] . '.');
assertEquals($widget, $wantedField['widget']['info']['label'], "{$name} doesn't have the widget type {$widget}. Instead it has " . $wantedField['widget']['info']['label'] . '.');
$fieldRequired = $wantedField['required'] ? 'required' : 'not required';
assertEquals($required, $fieldRequired, "{$name} is marked '{$fieldRequired}'. It should be '{$required}'.");
assertEquals($cardinality, $fieldInfo['cardinality'], "{$name} allows " . $fieldInfo['cardinality'] . " values. It should only allow {$cardinality} values.");
$this->fieldList[] = $wantedField['field_name'];
}
示例11: getTargetType
protected function getTargetType($field_name)
{
$field_info = \field_info_field($field_name);
if (!isset($field_info['settings']['target_type'])) {
throw new EntityReferenceHandlerException('The field ' . $field_name . ' does not have a proper target type.');
}
return $field_info['settings']['target_type'];
}
示例12: getExistingObject
public function getExistingObject(NodeInterface $node, Context $context)
{
/* @var $node FieldNode */
$name = $node->getName();
if ($info = field_info_field($name)) {
return $info;
}
$context->logCritical(sprintf("%s: does not exist", $node->getPath()));
}
示例13: isCompatible
/**
* Implements QuickEditInPlaceEditorInterface::isCompatible().
*
* @see Drupal 8's \Drupal\quickedit\Plugin\InPlaceEditor\PlainTextEditor::isCompatible().
*/
public function isCompatible(array $instance, array $items)
{
$field = field_info_field($instance['field_name']);
// This editor is incompatible with multivalued fields.
$cardinality_allows = $field['cardinality'] == 1;
// This editor is incompatible with processed ("rich") text fields.
$no_text_processing = empty($instance['settings']['text_processing']);
return $cardinality_allows && $no_text_processing;
}
示例14: installFields
public static function installFields(array $fields)
{
foreach ($fields as $index => $field) {
if (field_info_field($field['field_name'])) {
continue;
}
$fields[$index] = field_create_field($field);
}
return $fields;
}
示例15: publicFields
/**
* {@inheritdoc}
*/
protected function publicFields()
{
$public_fields = parent::publicFields();
$public_fields['nid'] = array('property' => 'node', 'sub_property' => 'nid');
// Add a custom field for test only.
if (field_info_field('comment_text')) {
$public_fields['comment_text'] = array('property' => 'comment_text', 'sub_property' => 'value');
}
return $public_fields;
}