protected function DefaultMenuLinkContentHandler::setEntityValues in CMS Content Sync 8
Same name and namespace in other branches
- 2.1.x src/Plugin/cms_content_sync/entity_handler/DefaultMenuLinkContentHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handler\DefaultMenuLinkContentHandler::setEntityValues()
- 2.0.x src/Plugin/cms_content_sync/entity_handler/DefaultMenuLinkContentHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handler\DefaultMenuLinkContentHandler::setEntityValues()
Set the values for the pulled entity.
Parameters
\Drupal\cms_content_sync\SyncIntent $intent:
\Drupal\Core\Entity\FieldableEntityInterface $entity: The translation of the entity
Return value
bool Returns TRUE when the values are set
Throws
\Drupal\Component\Plugin\Exception\PluginNotFoundException
\Drupal\cms_content_sync\Exception\SyncException
Overrides EntityHandlerBase::setEntityValues
See also
Flow::PULL_*
File
- src/
Plugin/ cms_content_sync/ entity_handler/ DefaultMenuLinkContentHandler.php, line 244
Class
- DefaultMenuLinkContentHandler
- Class DefaultMenuLinkContentHandler, providing a minimalistic implementation for menu items, making sure they're referenced correctly by UUID.
Namespace
Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handlerCode
protected function setEntityValues(PullIntent $intent, FieldableEntityInterface $entity = null) {
$result = parent::setEntityValues($intent, $entity);
if (SyncIntent::ACTION_DELETE != $intent
->getAction()) {
$module_handler = \Drupal::service('module_handler');
if ($module_handler
->moduleExists('menu_token')) {
$config_array = $intent
->getProperty('menu_token_options');
if (!empty($config_array)) {
$uuid = $intent
->getUuid();
$config_menu = \Drupal::entityTypeManager()
->getStorage('link_configuration_storage')
->load($uuid);
if (empty($config_menu)) {
$config_menu = \Drupal::entityTypeManager()
->getStorage('link_configuration_storage')
->create([
'id' => $uuid,
'label' => 'Menu token link configuration',
'linkid' => (string) $intent
->getProperty('link')[0]['uri'],
'configurationSerialized' => serialize($config_array),
]);
}
else {
$config_menu
->set('linkid', (string) $intent
->getProperty('link')[0]['uri']);
$config_menu
->set('configurationSerialized', serialize($config_array));
}
$config_menu
->save();
}
}
}
return $result;
}