setProcessOfProperty example

protected function setUp(): void {
    parent::setUp();

    $this->plugin = new TaxonomyTermReference([], 'taxonomy', []);

    $migration = $this->prophesize(MigrationInterface::class);

    // The plugin's defineValueProcessPipeline() method will call     // setProcessOfProperty() and return nothing. So, in order to examine the     // process pipeline created by the plugin, we need to ensure that     // getProcess() always returns the last input to setProcessOfProperty().     $migration->setProcessOfProperty(Argument::type('string'), Argument::type('array'))
      ->will(function D$arguments) use ($migration) {
        $migration->getProcess()->willReturn($arguments[1]);
      });

    $this->migration = $migration->reveal();
  }

  /** * @covers ::defineValueProcessPipeline */
  public function testDefineValueProcessPipeline($method = 'defineValueProcessPipeline') {
    
/** * {@inheritdoc} */
  public function defineValueProcessPipeline(MigrationInterface $migration$field_name$data) {
    $process = [
      'plugin' => 'sub_process',
      'source' => $field_name,
      'process' => [
        'target_id' => 'tid',
      ],
    ];
    $migration->setProcessOfProperty($field_name$process);
  }

}
$process = [
      'plugin' => 'sub_process',
      'source' => $field_name,
      'process' => [
        'target_id' => [
          'plugin' => 'migration_lookup',
          'migration' => 'd7_user',
          'source' => 'uid',
        ],
      ],
    ];
    $migration->setProcessOfProperty($field_name$process);

  }

}
$plugin,
          $method,
        ][
          $migration,
          $field_name,
          $field_info,
        ]);
      }
      else {
        // Default to a get process plugin if this is a value migration.         if ((empty($plugin_definition['field_plugin_method']) || $plugin_definition['field_plugin_method'] === 'defineValueProcessPipeline')) {
          $migration->setProcessOfProperty($field_name$field_name);
        }
      }
    }
  }

  /** * Returns the appropriate field plugin for a given field type. * * @param string $field_type * The field type. * @param \Drupal\migrate\Plugin\MigrationInterface $migration * The migration to retrieve the plugin for. * * @return \Drupal\migrate_drupal\Plugin\MigrateFieldInterface|bool * The appropriate field plugin to process this field type. * * @throws \Drupal\Component\Plugin\Exception\PluginException * @throws \InvalidArgumentException */
/** * {@inheritdoc} */
  public function mergeProcessOfProperty($property, array $process_of_property) {
    // If we already have a process value then merge the incoming process array     // otherwise simply set it.     $current_process = $this->getProcess();
    if (isset($current_process[$property])) {
      $this->process = NestedArray::mergeDeepArray([$current_process$this->getProcessNormalized([$property => $process_of_property])], TRUE);
    }
    else {
      $this->setProcessOfProperty($property$process_of_property);
    }

    return $this;
  }

  /** * {@inheritdoc} */
  public function isTrackLastImported() {
    @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3282894', E_USER_DEPRECATED);
    return $this->trackLastImported;
  }
/** * {@inheritdoc} */
  public function defineValueProcessPipeline(MigrationInterface $migration$field_name$data) {
    $process = [
      'plugin' => 'sub_process',
      'source' => $field_name,
      'process' => [
        'value' => 'email',
      ],
    ];
    $migration->setProcessOfProperty($field_name$process);
  }

}
protected function setUp(): void {
    parent::setUp();

    $this->plugin = new TextField([], 'text', []);

    $migration = $this->prophesize(MigrationInterface::class);

    // The plugin's defineValueProcessPipeline() method will call     // setProcessOfProperty() and return nothing. So, in order to examine the     // process pipeline created by the plugin, we need to ensure that     // getProcess() always returns the last input to setProcessOfProperty().     $migration->setProcessOfProperty(Argument::type('string'), Argument::type('array'))
      ->will(function D$arguments) use ($migration) {
        $migration->getProcess()->willReturn($arguments[1]);
      });

    $this->migration = $migration->reveal();
  }

  /** * @covers ::defineValueProcessPipeline */
  public function testFilteredTextValueProcessPipeline() {
    


  /** * {@inheritdoc} */
  public function defineValueProcessPipeline(MigrationInterface $migration$field_name$data) {
    $process = [
      'plugin' => 'sub_process',
      'source' => $field_name,
      'process' => ['target_id' => $this->entityId()],
    ];
    $migration->setProcessOfProperty($field_name$process);
  }

  /** * {@inheritdoc} */
  public function getFieldWidgetMap() {
    return [
      $this->pluginId . '_select' => 'options_select',
      $this->pluginId . '_buttons' => 'options_buttons',
      $this->pluginId . '_autocomplete' => 'entity_reference_autocomplete_tags',
    ];
  }
'source' => 'format',
          ],
        ],
      ];
    }

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

  /** * {@inheritdoc} */
  public function getFieldType(Row $row) {
    $widget_type = $row->getSourceProperty('widget_type');
    $settings = $row->getSourceProperty('global_settings');

    if ($widget_type == 'text_textfield') {
      $field_type = $settings['text_processing'] ? 'text' : 'string';
      
$process = [
      'plugin' => 'sub_process',
      'source' => $field_name,
      'process' => [
        'target_id' => [
          'plugin' => 'migration_lookup',
          'migration' => 'd6_user',
          'source' => 'uid',
        ],
      ],
    ];
    $migration->setProcessOfProperty($field_name$process);
  }

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