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


PHP FieldStorageDefinitionInterface::getName方法代码示例

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


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

示例1: getFieldIndexName

 /**
  * Generates an index name for a field data table.
  *
  * @param \Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition
  *   The field storage definition.
  * @param string $index
  *   The name of the index.
  *
  * @return string
  *   A string containing a generated index name for a field data table that is
  *   unique among all other fields.
  */
 protected function getFieldIndexName(FieldStorageDefinitionInterface $storage_definition, $index)
 {
     return $storage_definition->getName() . '_' . $index;
 }
开发者ID:sgtsaughter,项目名称:d8portfolio,代码行数:16,代码来源:SqlContentEntityStorageSchema.php

示例2: deleteLastInstalledFieldStorageDefinition

 /**
  * Deletes the field storage definition from the application state.
  *
  * @param \Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition
  *   The field storage definition.
  */
 protected function deleteLastInstalledFieldStorageDefinition(FieldStorageDefinitionInterface $storage_definition)
 {
     $entity_type_id = $storage_definition->getTargetEntityTypeId();
     $definitions = $this->getLastInstalledFieldStorageDefinitions($entity_type_id);
     unset($definitions[$storage_definition->getName()]);
     $this->setLastInstalledFieldStorageDefinitions($entity_type_id, $definitions);
 }
开发者ID:brstde,项目名称:gap1,代码行数:13,代码来源:EntityManager.php

示例3: storageDefinitionIsDeleted

 /**
  * Determines whether the passed field has been already deleted.
  *
  * @param \Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition
  *   The field storage definition.
  *
  * @return bool
  *   Whether the field has been already deleted.
  */
 protected function storageDefinitionIsDeleted(FieldStorageDefinitionInterface $storage_definition)
 {
     return !array_key_exists($storage_definition->getName(), $this->entityManager->getLastInstalledFieldStorageDefinitions($this->entityTypeId));
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:13,代码来源:SqlContentEntityStorage.php

示例4: generateFieldTableName

 /**
  * Generates a safe and unambiguous field table name.
  *
  * The method accounts for a maximum table name length of 64 characters, and
  * takes care of disambiguation.
  *
  * @param \Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition
  *   The field storage definition.
  * @param bool $revision
  *   TRUE for revision table, FALSE otherwise.
  *
  * @return string
  *   The final table name.
  */
 protected function generateFieldTableName(FieldStorageDefinitionInterface $storage_definition, $revision)
 {
     $separator = $revision ? '_revision__' : '__';
     $table_name = $storage_definition->getTargetEntityTypeId() . $separator . $storage_definition->getName();
     // Limit the string to 48 characters, keeping a 16 characters margin for db
     // prefixes.
     if (strlen($table_name) > 48) {
         // Use a shorter separator, a truncated entity_type, and a hash of the
         // field UUID.
         $separator = $revision ? '_r__' : '__';
         // Truncate to the same length for the current and revision tables.
         $entity_type = substr($storage_definition->getTargetEntityTypeId(), 0, 34);
         $field_hash = substr(hash('sha256', $storage_definition->getUniqueStorageIdentifier()), 0, 10);
         $table_name = $entity_type . $separator . $field_hash;
     }
     return $table_name;
 }
开发者ID:brstde,项目名称:gap1,代码行数:31,代码来源:DefaultTableMapping.php

示例5: _fieldColumnName

 /**
  * Generates a column name for a field data table.
  *
  * @private Calling this function circumvents the entity system and is
  * strongly discouraged. This function is not considered part of the public
  * API and modules relying on it might break even in minor releases. Only
  * call this function to write a query that \Drupal::entityQuery() does not
  * support. Always call entity_load() before using the data found in the
  * table.
  *
  * @param \Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition
  *   The field storage definition.
  * @param string $column
  *   The name of the column.
  *
  * @return string
  *   A string containing a generated column name for a field data table that is
  *   unique among all other fields.
  */
 public static function _fieldColumnName(FieldStorageDefinitionInterface $storage_definition, $column)
 {
     return in_array($column, FieldStorageConfig::getReservedColumns()) ? $column : $storage_definition->getName() . '_' . $column;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:23,代码来源:ContentEntityDatabaseStorage.php

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

示例7: updateFieldStorageDefinition

 /**
  * {@inheritdoc}
  */
 public function updateFieldStorageDefinition(FieldStorageDefinitionInterface $storage_definition)
 {
     $original = $this->getFieldStorageDefinition($storage_definition->getName(), $storage_definition->getTargetEntityTypeId());
     $this->entityManager->clearCachedDefinitions();
     $this->entityManager->onFieldStorageDefinitionUpdate($storage_definition, $original);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:9,代码来源:EntityDefinitionUpdateManager.php

示例8: storageDefinitionIsDeleted

 /**
  * Determines whether the passed field has been already deleted.
  *
  * @param \Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition
  *   The field storage definition.
  *
  * @return bool
  *   Whether the field has been already deleted.
  */
 protected function storageDefinitionIsDeleted(FieldStorageDefinitionInterface $storage_definition)
 {
     // Configurable fields are marked for deletion.
     if ($storage_definition instanceof FieldStorageConfigInterface) {
         return $storage_definition->isDeleted();
     }
     // For non configurable fields check whether they are still in the last
     // installed schema repository.
     return !array_key_exists($storage_definition->getName(), $this->entityManager->getLastInstalledFieldStorageDefinitions($this->entityTypeId));
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:19,代码来源:SqlContentEntityStorage.php

示例9: getFieldColumnName

 /**
  * {@inheritdoc}
  */
 public function getFieldColumnName(FieldStorageDefinitionInterface $storage_definition, $column)
 {
     return in_array($column, $this->getReservedColumns()) ? $column : $storage_definition->getName() . '_' . $column;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:7,代码来源:DefaultTableMapping.php

示例10: getAllFieldConfigsForField

 /**
  * {@inheritdoc}
  */
 public function getAllFieldConfigsForField(FieldStorageDefinitionInterface $definition, $entity_type_id)
 {
     $map = $this->entityFieldManager->getFieldMap()[$entity_type_id];
     $definitions = [];
     $field_name = $definition->getName();
     if (isset($map[$field_name])) {
         $bundles = $map[$field_name]['bundles'];
         foreach ($bundles as $bundle) {
             $bundle_definitions = $this->entityFieldManager->getFieldDefinitions($entity_type_id, $bundle);
             $definitions[$bundle] = $bundle_definitions[$field_name];
         }
     }
     return $definitions;
 }
开发者ID:tedbow,项目名称:scheduled-updates-demo,代码行数:17,代码来源:FieldManager.php

示例11: createFormDisplay

  /**
   * Create a form display for a newly clone field.
   *
   * This function attempts to use same setting settings as the source field.
   *
   * @param \Drupal\scheduled_updates\ScheduledUpdateTypeInterface $scheduled_update_type
   * @param $field_name
   * @param $field_config_id
   * @param $entity_type
   * @param $definition
   *  Source field definition
   * @param $new_field_name
   */
  protected function createFormDisplay(ScheduledUpdateTypeInterface $scheduled_update_type, $field_config_id, FieldStorageDefinitionInterface $definition, $new_field_name) {
    $destination_bundle = $scheduled_update_type->id();
    $field_name = $definition->getName();
    $entity_type = $scheduled_update_type->getUpdateEntityType();
    /** @var EntityFormDisplay $destination_form_display */
    $destination_form_display = EntityFormDisplay::load("scheduled_update.$destination_bundle.default");
    if (empty($destination_form_display)) {
      $destination_form_display = EntityFormDisplay::create([
        'targetEntityType' => 'scheduled_update',
        'bundle' => $destination_bundle,
        'mode' => 'default',
        'status' => TRUE,
      ]);
    }
    $display_options = [];
    if ($field_config_id) {
      $parts = explode('.', $field_config_id);
      $source_bundle = $parts[1];
      /** @var EntityFormDisplay $source_form_display */
      $source_form_display = EntityFormDisplay::load("$entity_type.$source_bundle.default");

      $display_options = $source_form_display->getComponent($field_name);
    }
    else {
      if ($definition instanceof BaseFieldDefinition) {
        $display_options = $definition->getDisplayOptions('form');
        if (empty($display_options)) {
          if ($definition->getType()) {
            // Provide default display for base boolean fields that don't have their own form display
            $display_options = [
              'type' => 'boolean_checkbox',
              'settings' => ['display_label' => TRUE],
            ];
          }
        }
      }
    }
    if (empty($display_options)) {
      $display_options = [];
    }
    if ($destination_form_display) {
      $destination_form_display->setComponent($new_field_name, $display_options);
      $destination_form_display->save();
    }
    else {
      // Alert user if display options could not be created.
      // @todo Create default display options even none on source.
      drupal_set_message(
        $this->t(
          'Form display options could not be created for @field they will have to be created manually.',
          ['@field' => $field_name]
        ),
        'warning');
    }
  }
开发者ID:joebachana,项目名称:usatne,代码行数:68,代码来源:FieldManager.php


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