getFieldType example

'plugin' => 'sub_process',
      'source' => $field_name,
      'process' => $process,
    ];
    $migration->mergeProcessOfProperty($field_name$process);
  }

  /** * {@inheritdoc} */
  public function getFieldType(Row $row) {
    $field_type = parent::getFieldType($row);

    // If the 'todate' setting is specified then change the field type to     // 'daterange' so we can migrate the end date.     if ($field_type === 'datetime' && !empty($row->get('settings/todate'))) {
      if (\Drupal::service('module_handler')->moduleExists('datetime_range')) {
        return 'daterange';
      }
      else {
        throw new MigrateException(sprintf("Can't migrate field '%s' with 'todate' settings. Enable the datetime_range module. See https://www.drupal.org/docs/8/upgrade/known-issues-when-upgrading-from-drupal-6-or-7-to-drupal-8#datetime", $row->get('field_name')));
      }
    }

    

  }

  /** * @covers ::getFieldType * @dataProvider getFieldTypeProvider */
  public function testGetFieldType($expected_type$widget_type, array $settings = []) {
    $row = new Row();
    $row->setSourceProperty('widget_type', $widget_type);
    $row->setSourceProperty('global_settings', $settings);
    $this->assertSame($expected_type$this->plugin->getFieldType($row));
  }

}
$migration
    );
  }

  /** * {@inheritdoc} */
  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row$destination_property) {
    $field_type = is_array($value) ? $value[0] : $value;
    try {
      $plugin_id = $this->fieldPluginManager->getPluginIdFromFieldType($field_type[]$this->migration);
      return $this->fieldPluginManager->createInstance($plugin_id[]$this->migration)->getFieldType($row);
    }
    catch (PluginNotFoundException $e) {
      return parent::transform($value$migrate_executable$row$destination_property);
    }
  }

}


        return $attributes;
    }

    private function resolveJsonField(JsonField $jsonField): Property
    {
        if ($jsonField instanceof ListField || $jsonField instanceof BreadcrumbField) {
            $definition = new Property([
                'type' => 'array',
                'property' => $jsonField->getPropertyName(),
                'items' => $this->getPropertyAssocsByField($jsonField instanceof ListField ? $jsonField->getFieldType() : null),
            ]);
        } else {
            $definition = new Property([
                'type' => 'object',
                'property' => $jsonField->getPropertyName(),
            ]);
        }

        $required = [];

        if (!empty($jsonField->getPropertyMapping())) {
            

  }

  /** * @covers ::getFieldType * @dataProvider getFieldTypeProvider */
  public function testGetFieldType($expected_type$widget_type, array $settings = []) {
    $row = new Row();
    $row->setSourceProperty('widget_type', $widget_type);
    $row->setSourceProperty('global_settings', $settings);
    $this->assertSame($expected_type$this->plugin->getFieldType($row));
  }

}

class TextField extends FieldPluginBase {

  /** * {@inheritdoc} */
  public function getFieldFormatterType(Row $row) {
    $field_type = $this->getFieldType($row);
    $formatter_type = $row->getSourceProperty('formatter/type');

    switch ($field_type) {
      case 'string':
        $formatter_type = str_replace(['text_default', 'text_plain'], 'string', $formatter_type);
        break;

      case 'string_long':
        $formatter_type = str_replace(['text_default', 'text_plain'], 'basic_string', $formatter_type);
        break;
    }

    


    switch ($widget_type) {
      case 'optionwidgets_buttons':
      case 'optionwidgets_select':
        return 'list_string';

      case 'optionwidgets_onoff':
        return 'boolean';

      default:
        return parent::getFieldType($row);
    }
  }

}
return array_values(json_decode((string) $value, true, 512, \JSON_THROW_ON_ERROR));
    }

    protected function getConstraints(Field $field): array
    {
        return [new Type('array')];
    }

    protected function validateTypes(ListField $field, array $values, WriteParameterBag $parameters): void
    {
        $fieldType = $field->getFieldType();
        if ($fieldType === null) {
            return;
        }

        $existence = EntityExistence::createEmpty();

        /** @var Field $listField */
        $listField = new $fieldType('key', 'key');
        $listField->compile($this->definitionRegistry);

        $nestedParameters = $parameters->cloneForSubresource(
            

  }

  /** * @covers ::getFieldType * @dataProvider getFieldTypeProvider */
  public function testGetFieldType($expected_type$widget_type, array $settings = []) {
    $row = new Row();
    $row->setSourceProperty('widget_type', $widget_type);
    $row->setSourceProperty('global_settings', $settings);
    $this->assertSame($expected_type$this->plugin->getFieldType($row));
  }

}
Home | Imprint | This part of the site doesn't use cookies.