You are here

public function DefaultMenuLinkContentHandler::push in CMS Content Sync 8

Same name and namespace in other branches
  1. 2.1.x src/Plugin/cms_content_sync/entity_handler/DefaultMenuLinkContentHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handler\DefaultMenuLinkContentHandler::push()
  2. 2.0.x src/Plugin/cms_content_sync/entity_handler/DefaultMenuLinkContentHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handler\DefaultMenuLinkContentHandler::push()

Parameters

\Drupal\cms_content_sync\PushIntent $intent: The request to store all relevant info at

Return value

bool Whether or not the content has been pushed. FALSE is a desired state, meaning nothing should be pushed according to config.

Throws

\Drupal\cms_content_sync\Exception\SyncException

Overrides EntityHandlerBase::push

File

src/Plugin/cms_content_sync/entity_handler/DefaultMenuLinkContentHandler.php, line 86

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_handler

Code

public function push(PushIntent $intent, EntityInterface $entity = null) {
  $result = parent::push($intent, $entity);
  if ($result && SyncIntent::ACTION_DELETE != $intent
    ->getAction()) {
    $module_handler = \Drupal::service('module_handler');
    if ($module_handler
      ->moduleExists('menu_token')) {
      $uuid = $intent
        ->getUuid();
      $config_menu = \Drupal::entityTypeManager()
        ->getStorage('link_configuration_storage')
        ->load($uuid);
      if (!empty($config_menu)) {
        $config_array = unserialize($config_menu
          ->get('configurationSerialized'));
        $intent
          ->setProperty('menu_token_options', $config_array);
      }
    }
  }
  return $result;
}