public function DefaultPanelizerHandler::push in CMS Content Sync 2.1.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::push()
- 2.0.x src/Plugin/cms_content_sync/field_handler/DefaultPanelizerHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\field_handler\DefaultPanelizerHandler::push()
Parameters
\Drupal\cms_content_sync\SyncIntent $intent:
Return value
bool Whether or not the content has been pushed. FALSE is a desired state, meaning the entity should not be pushed according to config.
Throws
\Drupal\cms_content_sync\Exception\SyncException
Overrides FieldHandlerBase::push
File
- src/
Plugin/ cms_content_sync/ field_handler/ DefaultPanelizerHandler.php, line 129
Class
- DefaultPanelizerHandler
- Providing a handler for the panelizer module.
Namespace
Drupal\cms_content_sync\Plugin\cms_content_sync\field_handlerCode
public function push(PushIntent $intent) {
$action = $intent
->getAction();
$entity = $intent
->getEntity();
if (PushIntent::PUSH_AUTOMATICALLY != $this->settings['export']) {
return false;
}
// Deletion doesn't require any action on field basis for static data.
if (SyncIntent::ACTION_DELETE == $action) {
return false;
}
$data = $entity
->get($this->fieldName)
->getValue();
foreach ($data as &$item) {
$display =& $item['panels_display'];
unset($display['storage_id']);
if (!empty($display['blocks'])) {
$blocks = [];
foreach ($display['blocks'] as $uuid => $definition) {
if ('block_content' == $definition['provider']) {
// Use entity ID, not config ID.
list($type, $uuid) = explode(':', $definition['id']);
$block = \Drupal::service('entity.repository')
->loadEntityByUuid($type, $uuid);
if ($this
->shouldPushReferencedBlocks()) {
$intent
->addDependency($block);
}
else {
$intent
->addReference($block);
}
}
elseif (!in_array($definition['provider'], self::SUPPORTED_PROVIDERS)) {
continue;
}
$blocks[$uuid] = $definition;
}
$display['blocks'] = $blocks;
}
}
$intent
->setProperty($this->fieldName, $data);
return true;
}