public function DefaultFormattedTextHandler::pull in CMS Content Sync 2.1.x
Same name and namespace in other branches
- 8 src/Plugin/cms_content_sync/field_handler/DefaultFormattedTextHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\field_handler\DefaultFormattedTextHandler::pull()
- 2.0.x src/Plugin/cms_content_sync/field_handler/DefaultFormattedTextHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\field_handler\DefaultFormattedTextHandler::pull()
Parameters
\Drupal\cms_content_sync\SyncIntent $intent: The request containing all pushed data
Return value
bool Whether or not the content has been pulled. FALSE is a desired state, meaning the entity should not be pulled according to config.
Throws
\Drupal\cms_content_sync\Exception\SyncException
Overrides FieldHandlerBase::pull
File
- src/
Plugin/ cms_content_sync/ field_handler/ DefaultFormattedTextHandler.php, line 36
Class
- DefaultFormattedTextHandler
- Providing a minimalistic implementation for any field type.
Namespace
Drupal\cms_content_sync\Plugin\cms_content_sync\field_handlerCode
public function pull(PullIntent $intent) {
$action = $intent
->getAction();
/**
* @var \Drupal\Core\Entity\FieldableEntityInterface $entity
*/
$entity = $intent
->getEntity();
// Deletion doesn't require any action on field basis for static data.
if (SyncIntent::ACTION_DELETE == $action) {
return false;
}
if ($intent
->shouldMergeChanges()) {
return false;
}
$data = $intent
->getProperty($this->fieldName);
if (empty($data)) {
$entity
->set($this->fieldName, null);
}
else {
$result = [];
foreach ($data as $item) {
if (!empty($item['value'])) {
// Replace node links correctly.
$item['value'] = $this
->replaceEntityReferenceLinks($item['value']);
}
$result[] = $item;
}
$entity
->set($this->fieldName, $result);
}
return true;
}