class DefaultWebformHandler in CMS Content Sync 2.1.x
Same name and namespace in other branches
- 8 src/Plugin/cms_content_sync/field_handler/DefaultWebformHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\field_handler\DefaultWebformHandler
- 2.0.x src/Plugin/cms_content_sync/field_handler/DefaultWebformHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\field_handler\DefaultWebformHandler
Implements webform references.
Plugin annotation
@FieldHandler(
id = "cms_content_sync_default_webform_handler",
label = @Translation("Default Webform"),
weight = 90
)
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\DefaultWebformHandler
- 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 DefaultWebformHandler
File
- src/
Plugin/ cms_content_sync/ field_handler/ DefaultWebformHandler.php, line 19
Namespace
Drupal\cms_content_sync\Plugin\cms_content_sync\field_handlerView source
class DefaultWebformHandler extends EntityReferenceHandlerBase {
/**
* {@inheritdoc}
*/
public static function supports($entity_type, $bundle, $field_name, FieldDefinitionInterface $field) {
if (!in_array($field
->getType(), [
'webform',
])) {
return false;
}
return true;
}
/**
* Don't expose option, but force push.
*
* @return bool
*/
protected function forcePushingReferencedEntities() {
return false;
}
/**
* @return bool
*/
protected function allowPushingReferencedEntities() {
return true;
}
/**
* Don't expose option, but force push.
*
* @return bool
*/
protected function forceEmbeddingReferencedEntities() {
return false;
}
/**
* @return string
*/
protected function getReferencedEntityTypes() {
return [
'webform',
];
}
/**
* Get the values to be set to the $entity->field_*.
*
* @param $reference
* @param \Drupal\cms_content_sync\PullIntent $intent
*
* @return array
*/
protected function getFieldValuesForReference($reference, $intent) {
return [
'target_id' => $reference
->id(),
];
}
/**
* @param $value
*
* @throws \Drupal\Core\Entity\EntityStorageException
* @throws \Drupal\cms_content_sync\Exception\SyncException
* @throws \GuzzleHttp\Exception\GuzzleException
*
* @return array|object
*/
protected function serializeReference(PushIntent $intent, EntityInterface $reference, $value) {
if ($this
->shouldEmbedReferencedEntities()) {
return $intent
->embed($reference, $value);
}
if ($this
->shouldPushReferencedEntities()) {
return $intent
->addDependency($reference, $value);
}
return $intent
->addReference($reference, $value);
}
}