public function DefaultMenuLinkContentHandler::ignorePush 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::ignorePush()
- 2.0.x src/Plugin/cms_content_sync/entity_handler/DefaultMenuLinkContentHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handler\DefaultMenuLinkContentHandler::ignorePush()
Check if the entity should not be ignored from the push.
Parameters
\Drupal\cms_content_sync\SyncIntent $intent: The Sync Core Request
\Drupal\Core\Entity\FieldableEntityInterface $entity: The entity that could be ignored
string $reason: The reason why the entity should be ignored from the push
string $action: The action to apply
Return value
bool Whether or not to ignore this push request
Throws
\Exception
Overrides EntityHandlerBase::ignorePush
File
- src/
Plugin/ cms_content_sync/ entity_handler/ DefaultMenuLinkContentHandler.php, line 200
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
public function ignorePush(PushIntent $intent) {
/**
* @var \Drupal\menu_link_content\Entity\MenuLinkContent $entity
*/
$entity = $intent
->getEntity();
if (!$entity
->isEnabled() && $this->settings['handler_settings']['ignore_unpublished']) {
return true;
}
if ($this
->shouldRestrictMenuUsage()) {
$menu = $entity
->getMenuName();
if (empty($this->settings['handler_settings']['restrict_menus'][$menu])) {
return true;
}
}
$uri = $entity
->get('link')
->getValue()[0]['uri'];
if ('entity:' == substr($uri, 0, 7)) {
preg_match('/^entity:(.*)\\/(\\d*)$/', $uri, $found);
// This means we're already dealing with a UUID that has not been resolved
// locally yet. So there's no sense in pushing this back to the pool.
if (empty($found)) {
return true;
}
$link_entity_type = $found[1];
$link_entity_id = $found[2];
$entity_manager = \Drupal::entityTypeManager();
$reference = $entity_manager
->getStorage($link_entity_type)
->load($link_entity_id);
// Dead reference > ignore.
if (empty($reference)) {
return true;
}
}
return parent::ignorePush($intent);
}