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


PHP FieldStorageDefinitionInterface::getDescription方法代码示例

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


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

示例1: 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

示例2: getSharedTableFieldSchema

 /**
  * Returns the schema for a single field definition.
  *
  * Entity types may override this method in order to optimize the generated
  * schema for given field. While all optimizations that apply to a single
  * field have to be added here, all cross-field optimizations should be via
  * SqlContentEntityStorageSchema::getEntitySchema() instead; e.g.,
  * an index spanning multiple fields.
  *
  * @param \Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition
  *   The storage definition of the field whose schema has to be returned.
  * @param string $table_name
  *   The name of the table columns will be added to.
  * @param string[] $column_mapping
  *   A mapping of field column names to database column names.
  *
  * @return array
  *   The schema definition for the table with the following keys:
  *   - fields: The schema definition for the each field columns.
  *   - indexes: The schema definition for the indexes.
  *   - unique keys: The schema definition for the unique keys.
  *   - foreign keys: The schema definition for the foreign keys.
  *
  * @throws \Drupal\Core\Field\FieldException
  *   Exception thrown if the schema contains reserved column names.
  */
 protected function getSharedTableFieldSchema(FieldStorageDefinitionInterface $storage_definition, $table_name, array $column_mapping)
 {
     $schema = array();
     $field_schema = $storage_definition->getSchema();
     // Check that the schema does not include forbidden column names.
     if (array_intersect(array_keys($field_schema['columns']), $this->storage->getTableMapping()->getReservedColumns())) {
         throw new FieldException(format_string('Illegal field column names on @field_name', array('@field_name' => $storage_definition->getName())));
     }
     $field_name = $storage_definition->getName();
     $field_description = $storage_definition->getDescription();
     foreach ($column_mapping as $field_column_name => $schema_field_name) {
         $column_schema = $field_schema['columns'][$field_column_name];
         $schema['fields'][$schema_field_name] = $column_schema;
         $schema['fields'][$schema_field_name]['description'] = $field_description;
         // Only entity keys are required.
         $keys = $this->entityType->getKeys() + array('langcode' => 'langcode');
         // The label is an entity key, but label fields are not necessarily
         // required.
         // Because entity ID and revision ID are both serial fields in the base
         // and revision table respectively, the revision ID is not known yet, when
         // inserting data into the base table. Instead the revision ID in the base
         // table is updated after the data has been inserted into the revision
         // table. For this reason the revision ID field cannot be marked as NOT
         // NULL.
         unset($keys['label'], $keys['revision']);
         // Key fields may not be NULL.
         if (in_array($field_name, $keys)) {
             $schema['fields'][$schema_field_name]['not null'] = TRUE;
         }
     }
     if (!empty($field_schema['indexes'])) {
         $schema['indexes'] = $this->getFieldIndexes($field_name, $field_schema, $column_mapping);
     }
     if (!empty($field_schema['unique keys'])) {
         $schema['unique keys'] = $this->getFieldUniqueKeys($field_name, $field_schema, $column_mapping);
     }
     if (!empty($field_schema['foreign keys'])) {
         $schema['foreign keys'] = $this->getFieldForeignKeys($field_name, $field_schema, $column_mapping);
     }
     return $schema;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:67,代码来源:SqlContentEntityStorageSchema.php


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