class DefaultMenuLinkContentReferenceHandler in CMS Content Sync 2.0.x
Same name and namespace in other branches
- 8 src/Plugin/cms_content_sync/field_handler/DefaultMenuLinkContentReferenceHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\field_handler\DefaultMenuLinkContentReferenceHandler
- 2.1.x src/Plugin/cms_content_sync/field_handler/DefaultMenuLinkContentReferenceHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\field_handler\DefaultMenuLinkContentReferenceHandler
Reference menu references and make sure they're published as the content comes available.
Plugin annotation
@FieldHandler(
id = "cms_content_sync_default_menu_link_content_reference_handler",
label = @Translation("Default Menu Link Content Reference"),
weight = 80
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\cms_content_sync\Plugin\FieldHandlerBase implements FieldHandlerInterface, ContainerFactoryPluginInterface
- class \Drupal\cms_content_sync\Plugin\EntityReferenceHandlerBase
- class \Drupal\cms_content_sync\Plugin\cms_content_sync\field_handler\DefaultEntityReferenceHandler
- class \Drupal\cms_content_sync\Plugin\cms_content_sync\field_handler\DefaultMenuLinkContentReferenceHandler
- class \Drupal\cms_content_sync\Plugin\cms_content_sync\field_handler\DefaultEntityReferenceHandler
- class \Drupal\cms_content_sync\Plugin\EntityReferenceHandlerBase
- class \Drupal\cms_content_sync\Plugin\FieldHandlerBase implements FieldHandlerInterface, ContainerFactoryPluginInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of DefaultMenuLinkContentReferenceHandler
File
- src/
Plugin/ cms_content_sync/ field_handler/ DefaultMenuLinkContentReferenceHandler.php, line 17
Namespace
Drupal\cms_content_sync\Plugin\cms_content_sync\field_handlerView source
class DefaultMenuLinkContentReferenceHandler extends DefaultEntityReferenceHandler {
/**
* {@inheritdoc}
*/
public static function supports($entity_type, $bundle, $field_name, FieldDefinitionInterface $field) {
return 'menu_link_content' == $entity_type && 'parent' == $field_name;
}
/**
* {@inheritdoc}
*/
protected function forcePushingReferencedEntities() {
return true;
}
/**
* {@inheritdoc}
*/
protected function loadReferencedEntityFromFieldValue($value) {
if (empty($value) || empty($value['value'])) {
return null;
}
list($entity_type, $uuid) = explode(':', $value['value']);
if ('menu_link_content' != $entity_type || empty($uuid)) {
return null;
}
return \Drupal::service('entity.repository')
->loadEntityByUuid('menu_link_content', $uuid);
}
/**
* {@inheritdoc}
*/
protected function getFieldValuesForReference($reference, $intent) {
return 'menu_link_content:' . $reference
->uuid();
}
/**
* {@inheritdoc}
*/
protected function getReferencedEntityTypes() {
return [
'menu_link_content',
];
}
}