DefaultWebformHandler.php in CMS Content Sync 8
File
src/Plugin/cms_content_sync/field_handler/DefaultWebformHandler.php
View source
<?php
namespace Drupal\cms_content_sync\Plugin\cms_content_sync\field_handler;
use Drupal\cms_content_sync\Plugin\EntityReferenceHandlerBase;
use Drupal\cms_content_sync\PushIntent;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
class DefaultWebformHandler extends EntityReferenceHandlerBase {
public static function supports($entity_type, $bundle, $field_name, FieldDefinitionInterface $field) {
if (!in_array($field
->getType(), [
'webform',
])) {
return false;
}
return true;
}
protected function forcePushingReferencedEntities() {
return false;
}
protected function allowPushingReferencedEntities() {
return true;
}
protected function forceEmbeddingReferencedEntities() {
return false;
}
protected function getReferencedEntityTypes() {
return [
'webform',
];
}
protected function getFieldValuesForReference($reference, $intent) {
return [
'target_id' => $reference
->id(),
];
}
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);
}
}