public function GatherContentMigrateSource::prepareRow in GatherContent 8.5
Adds additional data to the row.
Parameters
\Drupal\migrate\Row $row: The row object.
Return value
bool FALSE if this row needs to be skipped.
Overrides SourcePluginBase::prepareRow
File
- src/
Plugin/ migrate/ source/ GatherContentMigrateSource.php, line 257
Class
- GatherContentMigrateSource
- A source class for Gathercontent API.
Namespace
Drupal\gathercontent\Plugin\migrate\sourceCode
public function prepareRow(Row $row) {
$ret = parent::prepareRow($row);
if ($ret) {
$collectedMetaTags = [];
$gcId = $row
->getSourceProperty('id');
$gcItem = $this->client
->itemGet($gcId);
if (empty($gcItem)) {
return FALSE;
}
foreach ($gcItem->content as $fieldId => $field) {
$value = $this
->getFieldValue($field);
// Check if the field is for meta tags.
if (array_key_exists($fieldId, $this->metatagFields)) {
$collectedMetaTags[$this->metatagFields[$fieldId]] = $value;
continue;
}
/* @todo This section should be moved to getFieldValue() */
if (is_array($field)) {
foreach ($field as $subObject) {
if ($subObject instanceof ElementSimpleFile) {
/* Entity with image needs to update as the alt_text property of
* the image may have been updated/changed in GatherContent.
*/
if (in_array($fieldId, $this->fields)) {
$idMap = $row
->getIdMap();
$idMap['source_row_status'] = MigrateIdMapInterface::STATUS_NEEDS_UPDATE;
$row
->setIdMap($idMap);
}
continue;
}
$value[] = [
'value' => $this
->getFieldValue($subObject),
];
}
}
$row
->setSourceProperty($fieldId, $value);
}
$row
->setSourceProperty('item_title', $gcItem->name);
if (!empty($collectedMetaTags)) {
$value = $this
->prepareMetatags($collectedMetaTags);
$row
->setSourceProperty('meta_tags', $value);
}
}
return $ret;
}