本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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());
}
示例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;
}
示例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;
}