You are here

class TextField in Zircon Profile 8

Same name in this branch
  1. 8 core/modules/config_translation/src/FormElement/Textfield.php \Drupal\config_translation\FormElement\Textfield
  2. 8 core/lib/Drupal/Core/Render/Element/Textfield.php \Drupal\Core\Render\Element\Textfield
  3. 8 core/modules/text/src/Plugin/migrate/cckfield/TextField.php \Drupal\text\Plugin\migrate\cckfield\TextField
Same name and namespace in other branches
  1. 8.0 core/modules/text/src/Plugin/migrate/cckfield/TextField.php \Drupal\text\Plugin\migrate\cckfield\TextField

Plugin annotation


@MigrateCckField(
  id = "text"
)

Hierarchy

Expanded class hierarchy of TextField

1 file declares its use of TextField
TextFieldTest.php in core/modules/text/tests/src/Unit/Migrate/TextFieldTest.php
Contains \Drupal\Tests\text\Unit\Migrate\TextFieldTest.

File

core/modules/text/src/Plugin/migrate/cckfield/TextField.php, line 19
Contains \Drupal\text\Plugin\migrate\cckfield\TextField.

Namespace

Drupal\text\Plugin\migrate\cckfield
View source
class TextField extends CckFieldPluginBase {

  /**
   * {@inheritdoc}
   */
  public function getFieldWidgetMap() {
    return [
      'text_textfield' => 'text_textfield',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function getFieldFormatterMap() {
    return [
      'default' => 'text_default',
      'trimmed' => 'text_trimmed',
      'plain' => 'basic_string',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function processCckFieldValues(MigrationInterface $migration, $field_name, $field_info) {
    if ($field_info['widget_type'] == 'optionwidgets_onoff') {
      $process = [
        'value' => [
          'plugin' => 'static_map',
          'source' => 'value',
          'default_value' => 0,
        ],
      ];
      $checked_value = explode("\n", $field_info['global_settings']['allowed_values'])[1];
      if (strpos($checked_value, '|') !== FALSE) {
        $checked_value = substr($checked_value, 0, strpos($checked_value, '|'));
      }
      $process['value']['map'][$checked_value] = 1;
    }
    else {

      // See \Drupal\migrate_drupal\Plugin\migrate\source\d6\User::baseFields(),
      // signature_format for an example of the YAML that represents this
      // process array.
      $process = [
        'value' => 'value',
        'format' => [
          [
            'plugin' => 'static_map',
            'bypass' => TRUE,
            'source' => 'format',
            'map' => [
              0 => NULL,
            ],
          ],
          [
            'plugin' => 'skip_on_empty',
            'method' => 'process',
          ],
          [
            'plugin' => 'migration',
            'migration' => [
              'd6_filter_format',
              'd7_filter_format',
            ],
            'source' => 'format',
          ],
        ],
      ];
    }
    $process = array(
      'plugin' => 'iterator',
      'source' => $field_name,
      'process' => $process,
    );
    $migration
      ->setProcessOfProperty($field_name, $process);
  }

  /**
   * {@inheritdoc}
   */
  public function getFieldType(Row $row) {
    $widget_type = $row
      ->getSourceProperty('widget_type');
    if ($widget_type == 'text_textfield') {
      $settings = $row
        ->getSourceProperty('global_settings');
      $field_type = $settings['text_processing'] ? 'text' : 'string';
      if (empty($settings['max_length']) || $settings['max_length'] > 255) {
        $field_type .= '_long';
      }
      return $field_type;
    }
    else {
      switch ($widget_type) {
        case 'optionwidgets_buttons':
        case 'optionwidgets_select':
          return 'list_string';
        case 'optionwidgets_onoff':
          return 'boolean';
        case 'text_textarea':
          return 'text_long';
        default:
          break;
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CckFieldPluginBase::processField public function Apply any custom processing to the field migration. Overrides MigrateCckFieldInterface::processField
CckFieldPluginBase::processFieldFormatter public function Apply any custom processing to the field formatter migration. Overrides MigrateCckFieldInterface::processFieldFormatter
CckFieldPluginBase::processFieldInstance public function Apply any custom processing to the field instance migration. Overrides MigrateCckFieldInterface::processFieldInstance
CckFieldPluginBase::processFieldWidget public function Apply any custom processing to the field widget migration. Overrides MigrateCckFieldInterface::processFieldWidget
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
PluginBase::$configuration protected property Configuration information passed into the plugin. 2
PluginBase::$pluginDefinition protected property The plugin implementation definition.
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::__construct public function Constructs a Drupal\Component\Plugin\PluginBase object. 69
StringTranslationTrait::$stringTranslation protected property The string translation service.
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
TextField::getFieldFormatterMap public function Get a map between D6 formatters and D8 formatters for this field type. Overrides MigrateCckFieldInterface::getFieldFormatterMap
TextField::getFieldType public function Computes the destination type of a migrated field. Overrides CckFieldPluginBase::getFieldType
TextField::getFieldWidgetMap public function Get a map between D6 and D8 widgets for this field type. Overrides CckFieldPluginBase::getFieldWidgetMap
TextField::processCckFieldValues public function Apply any custom processing to the cck bundle migrations. Overrides MigrateCckFieldInterface::processCckFieldValues