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


PHP FieldStorageDefinitionInterface::getSettings方法代码示例

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


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

示例1: propertyDefinitions

 /**
  * {@inheritdoc}
  */
 public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition)
 {
     $settings = $field_definition->getSettings();
     $target_type_info = \Drupal::entityManager()->getDefinition($settings['target_type']);
     $target_id_data_type = 'string';
     if ($target_type_info->isSubclassOf('\\Drupal\\Core\\Entity\\FieldableEntityInterface')) {
         $id_definition = \Drupal::entityManager()->getBaseFieldDefinitions($settings['target_type'])[$target_type_info->getKey('id')];
         if ($id_definition->getType() === 'integer') {
             $target_id_data_type = 'integer';
         }
     }
     if ($target_id_data_type === 'integer') {
         $target_id_definition = DataDefinition::create('integer')->setLabel(t('@label ID', array($target_type_info->getLabel())))->setSetting('unsigned', TRUE);
     } else {
         $target_id_definition = DataDefinition::create('string')->setLabel(t('@label ID', array($target_type_info->getLabel())));
     }
     $target_id_definition->setRequired(TRUE);
     $properties['target_id'] = $target_id_definition;
     $properties['entity'] = DataReferenceDefinition::create('entity')->setLabel($target_type_info->getLabel())->setDescription(t('The referenced entity'))->setComputed(TRUE)->setReadOnly(FALSE)->setTargetDefinition(EntityDataDefinition::create($settings['target_type']))->addConstraint('EntityType', $settings['target_type']);
     if (isset($settings['target_bundle'])) {
         $properties['entity']->addConstraint('Bundle', $settings['target_bundle']);
         // Set any further bundle constraints on the target definition as well,
         // such that it can derive more special data types if possible. For
         // example, "entity:node:page" instead of "entity:node".
         $properties['entity']->getTargetDefinition()->addConstraint('Bundle', $settings['target_bundle']);
     }
     return $properties;
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:31,代码来源:EntityReferenceItem.php

示例2: propertyDefinitions

 /**
  * {@inheritdoc}
  */
 public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition)
 {
     $settings = $field_definition->getSettings();
     $target_type_info = \Drupal::entityTypeManager()->getDefinition($settings['target_type']);
     $properties = parent::propertyDefinitions($field_definition);
     if ($target_type_info->getKey('revision')) {
         $target_revision_id_definition = DataReferenceTargetDefinition::create('integer')->setLabel(t('@label revision ID', array('@label' => $target_type_info->getLabel())))->setSetting('unsigned', TRUE);
         $target_revision_id_definition->setRequired(TRUE);
         $properties['target_revision_id'] = $target_revision_id_definition;
     }
     $properties['entity'] = DataReferenceDefinition::create('entity_revision')->setLabel($target_type_info->getLabel())->setDescription(t('The referenced entity revision'))->setComputed(TRUE)->setReadOnly(FALSE)->setTargetDefinition(EntityDataDefinition::create($settings['target_type']));
     return $properties;
 }
开发者ID:eric-shell,项目名称:eric-shell-d8,代码行数:16,代码来源:EntityReferenceRevisionsItem.php

示例3: propertyDefinitions

 /**
  * {@inheritdoc}
  */
 public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition)
 {
     $settings = $field_definition->getSettings();
     $target_type_info = \Drupal::entityManager()->getDefinition($settings['target_type']);
     if ($target_type_info->isSubclassOf('\\Drupal\\Core\\Entity\\FieldableEntityInterface')) {
         // @todo: Lookup the entity type's ID data type and use it here.
         // https://drupal.org/node/2107249
         $target_id_definition = DataDefinition::create('integer')->setLabel(t('@label ID', array($target_type_info->getLabel())))->setSetting('unsigned', TRUE);
     } else {
         $target_id_definition = DataDefinition::create('string')->setLabel(t('@label ID', array($target_type_info->getLabel())));
     }
     $properties['target_id'] = $target_id_definition;
     $properties['entity'] = DataReferenceDefinition::create('entity')->setLabel($target_type_info->getLabel())->setDescription(t('The referenced entity'))->setComputed(TRUE)->setReadOnly(FALSE)->setTargetDefinition(EntityDataDefinition::create($settings['target_type']));
     if (isset($settings['target_bundle'])) {
         $properties['entity']->getTargetDefinition()->addConstraint('Bundle', $settings['target_bundle']);
     }
     return $properties;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:21,代码来源:EntityReferenceItem.php

示例4: propertyDefinitions

 /**
  * {@inheritdoc}
  */
 public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition)
 {
     $settings = $field_definition->getSettings();
     $target_type_info = \Drupal::entityManager()->getDefinition($settings['target_type']);
     $target_id_data_type = 'string';
     if ($target_type_info->isSubclassOf('\\Drupal\\Core\\Entity\\FieldableEntityInterface')) {
         $id_definition = \Drupal::entityManager()->getBaseFieldDefinitions($settings['target_type'])[$target_type_info->getKey('id')];
         if ($id_definition->getType() === 'integer') {
             $target_id_data_type = 'integer';
         }
     }
     if ($target_id_data_type === 'integer') {
         $target_id_definition = DataReferenceTargetDefinition::create('integer')->setLabel(new TranslatableMarkup('@label ID', ['@label' => $target_type_info->getLabel()]))->setSetting('unsigned', TRUE);
     } else {
         $target_id_definition = DataReferenceTargetDefinition::create('string')->setLabel(new TranslatableMarkup('@label ID', ['@label' => $target_type_info->getLabel()]));
     }
     $target_id_definition->setRequired(TRUE);
     $properties['target_id'] = $target_id_definition;
     $properties['entity'] = DataReferenceDefinition::create('entity')->setLabel($target_type_info->getLabel())->setDescription(new TranslatableMarkup('The referenced entity'))->setComputed(TRUE)->setReadOnly(FALSE)->setTargetDefinition(EntityDataDefinition::create($settings['target_type']))->addConstraint('EntityType', $settings['target_type']);
     return $properties;
 }
开发者ID:318io,项目名称:318-io,代码行数:24,代码来源:EntityReferenceItem.php

示例5: createFromFieldStorageDefinition

 /**
  * Creates a new field definition based upon a field storage definition.
  *
  * In cases where one needs a field storage definitions to act like full
  * field definitions, this creates a new field definition based upon the
  * (limited) information available. That way it is possible to use the field
  * definition in places where a full field definition is required; e.g., with
  * widgets or formatters.
  *
  * @param \Drupal\Core\Field\FieldStorageDefinitionInterface $definition
  *   The field storage definition to base the new field definition upon.
  *
  * @return $this
  */
 public static function createFromFieldStorageDefinition(FieldStorageDefinitionInterface $definition)
 {
     return static::create($definition->getType())->setCardinality($definition->getCardinality())->setConstraints($definition->getConstraints())->setCustomStorage($definition->hasCustomStorage())->setDescription($definition->getDescription())->setLabel($definition->getLabel())->setName($definition->getName())->setProvider($definition->getProvider())->setQueryable($definition->isQueryable())->setRequired($definition->isRequired())->setRevisionable($definition->isRevisionable())->setSettings($definition->getSettings())->setTargetEntityTypeId($definition->getTargetEntityTypeId())->setTranslatable($definition->isTranslatable());
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:18,代码来源:FieldDefinition.php

示例6: propertyDefinitions

 /**
  * {@inheritdoc}
  */
 public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition)
 {
     $subfield_types = self::subfieldTypes();
     $settings = $field_definition->getSettings();
     foreach (['first', 'second'] as $subfield) {
         $subfield_type = $settings['storage'][$subfield]['type'];
         // Typed data are slightly different from schema the definition.
         if ($subfield_type == 'text') {
             $subfield_type = 'string';
         } elseif ($subfield_type == 'numeric') {
             $subfield_type = 'float';
         }
         $properties[$subfield] = DataDefinition::create($subfield_type)->setLabel($subfield_types[$subfield_type]);
     }
     return $properties;
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:19,代码来源:DoubleField.php

示例7: propertyDefinitions

 /**
  * {@inheritdoc}
  */
 public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition)
 {
     $settings = $field_definition->getSettings();
     $target_type = $settings['target_type'];
     // Call the parent to define the target_id and entity properties.
     $properties = parent::propertyDefinitions($field_definition);
     // Only add the revision ID property if the target entity type supports
     // revisions.
     $target_type_info = \Drupal::entityManager()->getDefinition($target_type);
     if ($target_type_info->hasKey('revision') && $target_type_info->getRevisionTable()) {
         $properties['revision_id'] = DataDefinition::create('integer')->setLabel(t('Revision ID'))->setSetting('unsigned', TRUE);
     }
     return $properties;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:17,代码来源:ConfigurableEntityReferenceItem.php


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