DefaultFieldCollectionItemHandler.php in CMS Content Sync 2.0.x
File
src/Plugin/cms_content_sync/entity_handler/DefaultFieldCollectionItemHandler.php
View source
<?php
namespace Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handler;
use Drupal\cms_content_sync\Plugin\cms_content_sync\field_handler\DefaultFieldCollectionHandler;
use Drupal\cms_content_sync\Plugin\EntityHandlerBase;
use Drupal\cms_content_sync\PullIntent;
use Drupal\cms_content_sync\PushIntent;
class DefaultFieldCollectionItemHandler extends EntityHandlerBase {
public static function supports($entity_type, $bundle) {
return 'field_collection_item' == $entity_type;
}
public function getAllowedPushOptions() {
return [
PushIntent::PUSH_DISABLED,
PushIntent::PUSH_AS_DEPENDENCY,
];
}
public function getAllowedPullOptions() {
return [
PullIntent::PULL_DISABLED,
PullIntent::PULL_AS_DEPENDENCY,
];
}
public function getAllowedPreviewOptions() {
return [
'table' => 'Table',
'preview_mode' => 'Preview mode',
];
}
public function getForbiddenFields() {
$forbidden = parent::getForbiddenFields();
$forbidden[] = 'host_type';
return $forbidden;
}
protected function createNew(PullIntent $intent) {
$entity = parent::createNew($intent);
$parent = DefaultFieldCollectionHandler::$currentPullIntent
->getEntity();
if ($parent
->isNew()) {
$parent
->save();
}
$entity
->setHostEntity($parent);
return $entity;
}
protected function saveEntity($entity, $intent) {
}
}