public function DefaultPanelizerHandler::pull in CMS Content Sync 2.0.x
Same name and namespace in other branches
- 8 src/Plugin/cms_content_sync/field_handler/DefaultPanelizerHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\field_handler\DefaultPanelizerHandler::pull()
- 2.1.x src/Plugin/cms_content_sync/field_handler/DefaultPanelizerHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\field_handler\DefaultPanelizerHandler::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/ DefaultPanelizerHandler.php, line 68
Class
- DefaultPanelizerHandler
- Providing a handler for the panelizer module.
Namespace
Drupal\cms_content_sync\Plugin\cms_content_sync\field_handlerCode
public function pull(PullIntent $intent) {
$action = $intent
->getAction();
$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;
}
if (PullIntent::PULL_AUTOMATICALLY != $this->settings['import']) {
return false;
}
$data = $intent
->getProperty($this->fieldName);
if (empty($data)) {
$entity
->set($this->fieldName, null);
}
else {
$blockManager = \Drupal::service('plugin.manager.block');
foreach ($data as &$item) {
$display =& $item['panels_display'];
if (!empty($display['blocks'])) {
$values = [];
$blockCollection = new BlockPluginCollection($blockManager, $display['blocks']);
foreach ($display['blocks'] as $uuid => $definition) {
if ('block_content' == $definition['provider']) {
// Use entity ID, not config ID.
list($type, $block_uuid) = explode(':', $definition['id']);
$block = \Drupal::service('entity.repository')
->loadEntityByUuid($type, $block_uuid);
if (!$block) {
continue;
}
}
elseif (!in_array($definition['provider'], self::SUPPORTED_PROVIDERS)) {
continue;
}
if (!$blockCollection
->get($uuid)) {
$blockCollection
->addInstanceId($uuid, $definition);
}
$values[$uuid] = $definition;
}
$display['blocks'] = $values;
}
}
$entity
->set($this->fieldName, $data);
}
return true;
}