• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP field_info_field函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中field_info_field函数的典型用法代码示例。如果您正苦于以下问题:PHP field_info_field函数的具体用法?PHP field_info_field怎么用?PHP field_info_field使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了field_info_field函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
 }
开发者ID:jhoffman-tm,项目名称:waldorf-deployment,代码行数:29,代码来源:TestArticles__1_2.php


示例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));
 }
开发者ID:juanmnl07,项目名称:dandeleon,代码行数:31,代码来源:MultifieldEntityController.php


示例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;
 }
开发者ID:jhoffman-tm,项目名称:waldorf-deployment,代码行数:29,代码来源:ResourceFieldEntityText.php


示例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' => ''));
            }
        }
    }
}
开发者ID:signaltrace-dev,项目名称:d7-theme-bunsen,代码行数:28,代码来源:node.vars.php


示例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' => ''));
     }
 }
开发者ID:wesnick,项目名称:drupal-bootstrap,代码行数:7,代码来源:FieldBuilder.php


示例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;
 }
开发者ID:drupalconnect,项目名称:finsearches,代码行数:10,代码来源:EditEntityFieldAccessCheck.php


示例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;
 }
开发者ID:makinacorpus,项目名称:drupal-usync,代码行数:27,代码来源:ViewModeLoader.php


示例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;
}
开发者ID:JKeySZR,项目名称:GraphML,代码行数:33,代码来源:drupal.php


示例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'];
 }
开发者ID:promet,项目名称:drupal-behat-extension,代码行数:28,代码来源:ContentTypeContext.php


示例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'];
 }
开发者ID:sammarks,项目名称:publisher,代码行数:8,代码来源:EntityReferenceHandler.php


示例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()));
 }
开发者ID:makinacorpus,项目名称:drupal-usync,代码行数:9,代码来源:FieldLoader.php


示例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;
 }
开发者ID:kittiradovics,项目名称:WalkHub,代码行数:14,代码来源:plainTextEditor.php


示例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;
 }
开发者ID:juampynr,项目名称:DrupalCampEs,代码行数:10,代码来源:ProfileHelper.php


示例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;
 }
开发者ID:jhoffman-tm,项目名称:waldorf-deployment,代码行数:13,代码来源:Comments__1_0.php


示例16: getUserEntityFieldInfo

 /**
  * @param string $field_name
  *   Machine name or label of a field.
  *
  * @return array
  *   Drupal field definition.
  */
 public static function getUserEntityFieldInfo($field_name)
 {
     $locators = self::getUserEntityFields('locators');
     $field = [];
     // Try to find a field by label or machine name.
     if (isset($locators[$field_name])) {
         $field = field_info_field($locators[$field_name]);
     }
     // This check is necessary for always return an array only.
     return empty($field) ? [] : $field;
 }
开发者ID:spheresh,项目名称:behat-drupal-propeople-context,代码行数:18,代码来源:UserEntity.php


示例17: publicFieldsInfo

  /**
   * Overrides RestfulExampleArticlesResource::publicFieldsInfo().
   */
  public function publicFieldsInfo() {
    $public_fields = parent::publicFieldsInfo();

    $public_fields['body'] = array(
      'property' => 'body',
      'sub_property' => 'value',
    );

    $public_fields['tags'] = array(
      'property' => 'field_tags',
      'resource' => array(
        'tags' => 'tags',
      ),
    );

    $public_fields['image'] = array(
      'property' => 'field_image',
      'process_callbacks' => array(
        array($this, 'imageProcess'),
      ),
      'image_styles' => array('thumbnail', 'medium', 'large'),
    );

    // By checking that the field exists, we allow re-using this class on
    // different tests, where different fields exist.
    if (field_info_field('field_images')) {
      $public_fields['images'] = array(
        'property' => 'field_images',
        'process_callbacks' => array(
          array($this, 'imageProcess'),
        ),
        'image_styles' => array('thumbnail', 'medium', 'large'),
      );
    }

    $public_fields['user'] = array(
      'property' => 'author',
      'resource' => array(
        // The bundle of the entity.
        'user' => array(
          // The name of the resource to map to.
          'name' => 'users',
          // Determines if the entire resource should appear, or only the ID.
          'full_view' => TRUE,
        ),
      ),
    );

    $public_fields['static'] = array(
      'callback' => 'static::randomNumber',
    );

    return $public_fields;
  }
开发者ID:humanitarianresponse,项目名称:site,代码行数:57,代码来源:RestfulExampleArticlesResource__1_5.class.php


示例18: testFieldSaving

 /**
  * Test base field saving.
  *
  * @dataProvider fieldDataProvider
  */
 public function testFieldSaving($field_name, $vocabulary_name)
 {
     $service = multisite_config_service('field');
     $service->createBaseField($field_name, 'taxonomy_term_reference')->setVocabulary($vocabulary_name)->save();
     $field = field_info_field($field_name);
     $this->assertEquals('taxonomy_term_reference', $field['type']);
     $this->assertEquals($field_name, $field['field_name']);
     $this->assertEquals('taxonomy', $field['module']);
     $this->assertEquals(1, $field['cardinality']);
     $this->assertEquals($vocabulary_name, $field['settings']['allowed_values'][0]['vocabulary']);
     field_delete_field($field_name);
 }
开发者ID:janoka,项目名称:platform-dev,代码行数:17,代码来源:TaxonomyTermReferenceFieldHandlerTest.php


示例19: field_collection_fieldset_field_as_label_callback

/**
 * Callback to return a field collection label.
 *
 * @param array $context
 *   An array with contextual information used to build the title:
 *     - field_as_label the name of the field used as label.
 *     - field_collection_item_wrapper the field collection for which
 *     a label is created.
 *
 * @return string
 *   Title for the field collection.
 */
function field_collection_fieldset_field_as_label_callback($context)
{
    $title = '';
    if ($field_value = $context['field_collection_item_wrapper']->{$context['field_as_label']}->value()) {
        $info = field_info_field($context['field_as_label']);
        switch ($info['field_type']) {
            case 'text':
                $title = is_array($field_value) ? strip_tags($field_value['value']) : strip_tags($field_value);
                break;
        }
    }
    return $title;
}
开发者ID:jieyyal,项目名称:d7-demo,代码行数:25,代码来源:field_collection_fieldset.api.php


示例20: reference

 public static function reference($type, $value, $name)
 {
     if (!self::checkFieldValue($value, 'target_id')) {
         return null;
     }
     $info = field_info_field($name);
     if (!isset($info['settings']['target_type'])) {
         trigger_error('Target type couldnt be found.', E_USER_WARNING);
         return null;
     }
     $target_type = $info['settings']['target_type'];
     return new EntityReferenceFieldValue($type, $value, $target_type);
 }
开发者ID:ryne-andal,项目名称:ablecore,代码行数:13,代码来源:EntityReference.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP field_info_instance函数代码示例发布时间:2022-05-15
下一篇:
PHP field_get_items函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap