function EntityContentBase::processStubRow
Populates as much of the stub row as possible.
This method can be implemented in extending classes when needed.
Parameters
\Drupal\migrate\Row $row: The row of data.
Overrides Entity::processStubRow
4 calls to EntityContentBase::processStubRow()
- EntityComment::processStubRow in core/modules/ comment/ src/ Plugin/ migrate/ destination/ EntityComment.php 
- Populates as much of the stub row as possible.
- EntityContentComplete::getEntity in core/modules/ migrate/ src/ Plugin/ migrate/ destination/ EntityContentComplete.php 
- Gets the entity.
- EntityFile::processStubRow in core/modules/ file/ src/ Plugin/ migrate/ destination/ EntityFile.php 
- Populates as much of the stub row as possible.
- EntityUser::processStubRow in core/modules/ user/ src/ Plugin/ migrate/ destination/ EntityUser.php 
- Populates as much of the stub row as possible.
3 methods override EntityContentBase::processStubRow()
- EntityComment::processStubRow in core/modules/ comment/ src/ Plugin/ migrate/ destination/ EntityComment.php 
- Populates as much of the stub row as possible.
- EntityFile::processStubRow in core/modules/ file/ src/ Plugin/ migrate/ destination/ EntityFile.php 
- Populates as much of the stub row as possible.
- EntityUser::processStubRow in core/modules/ user/ src/ Plugin/ migrate/ destination/ EntityUser.php 
- Populates as much of the stub row as possible.
File
- 
              core/modules/ migrate/ src/ Plugin/ migrate/ destination/ EntityContentBase.php, line 344 
Class
- EntityContentBase
- Provides destination class for all content entities lacking a specific class.
Namespace
Drupal\migrate\Plugin\migrate\destinationCode
protected function processStubRow(Row $row) {
  $bundle_key = $this->getKey('bundle');
  if ($bundle_key && empty($row->getDestinationProperty($bundle_key))) {
    if (empty($this->bundles)) {
      throw new MigrateException('Stubbing failed, no bundles available for entity type: ' . $this->storage
        ->getEntityTypeId());
    }
    $row->setDestinationProperty($bundle_key, reset($this->bundles));
  }
  $bundle = $row->getDestinationProperty($bundle_key) ?? $this->storage
    ->getEntityTypeId();
  // Populate any required fields not already populated.
  $fields = $this->entityFieldManager
    ->getFieldDefinitions($this->storage
    ->getEntityTypeId(), $bundle);
  foreach ($fields as $field_name => $field_definition) {
    if ($field_definition->isRequired() && is_null($row->getDestinationProperty($field_name))) {
      // Use the configured default value for this specific field, if any.
      if ($default_value = $field_definition->getDefaultValueLiteral()) {
        $values = $default_value;
      }
      else {
        /** @var \Drupal\Core\Field\FieldItemInterface $field_type_class */
        $field_type_class = $this->fieldTypeManager
          ->getPluginClass($field_definition->getType());
        $values = $field_type_class::generateSampleValue($field_definition);
        if (is_null($values)) {
          // Handle failure to generate a sample value.
          throw new MigrateException('Stubbing failed, unable to generate value for field ' . $field_name);
        }
      }
      $row->setDestinationProperty($field_name, $values);
    }
  }
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
