class DefaultContentEntityHandler in CMS Content Sync 2.0.x
Same name and namespace in other branches
- 8 src/Plugin/cms_content_sync/entity_handler/DefaultContentEntityHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handler\DefaultContentEntityHandler
- 2.1.x src/Plugin/cms_content_sync/entity_handler/DefaultContentEntityHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handler\DefaultContentEntityHandler
Class DefaultContentEntityHandler, providing a minimalistic implementation for any content entity type.
Plugin annotation
@EntityHandler(
id = "cms_content_sync_default_entity_handler",
label = @Translation("Default Content"),
weight = 100
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\cms_content_sync\Plugin\EntityHandlerBase implements EntityHandlerInterface, ContainerFactoryPluginInterface
- class \Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handler\DefaultContentEntityHandler
- class \Drupal\cms_content_sync\Plugin\EntityHandlerBase implements EntityHandlerInterface, ContainerFactoryPluginInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of DefaultContentEntityHandler
File
- src/
Plugin/ cms_content_sync/ entity_handler/ DefaultContentEntityHandler.php, line 18
Namespace
Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handlerView source
class DefaultContentEntityHandler extends EntityHandlerBase {
/**
* {@inheritdoc}
*/
public static function supports($entity_type, $bundle) {
// Whitelist supported entity types.
$entity_types = [
'block_content',
'config_pages',
'paragraph',
'paragraphs_library_item',
'bibcite_contributor',
'bibcite_reference',
'bibcite_keyword',
'redirect',
];
$moduleHandler = \Drupal::service('module_handler');
$eck_exists = $moduleHandler
->moduleExists('eck');
if ($eck_exists) {
$eck_entity_type = \Drupal::entityTypeManager()
->getStorage('eck_entity_type')
->load($entity_type);
if (!empty($eck_entity_type)) {
return true;
}
}
return in_array($entity_type, $entity_types);
}
/**
* {@inheritdoc}
*/
public function getAllowedPreviewOptions() {
return [
'table' => 'Table',
'preview_mode' => 'Preview mode',
];
}
/**
* {@inheritdoc}
*/
public function getForbiddenFields() {
// Ignore paragraphs parent_id as it is a reference id.
return array_merge(parent::getForbiddenFields(), [
'parent_id',
]);
}
public function getViewUrl(EntityInterface $entity) {
if ('paragraph' === $entity
->getEntityTypeId()) {
$parent = $entity;
do {
$parent = $parent
->getParentEntity();
} while ($parent && 'paragraph' === $parent
->getEntityTypeId());
if (!$parent) {
throw new \Exception("Paragraphs can't be syndicated without being embedded in Content Sync v2.");
}
return parent::getViewUrl($parent);
}
return parent::getViewUrl($entity);
}
/**
* Check whether the entity type supports having a label.
*
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*
* @return bool
*/
protected function hasLabelProperty() {
$moduleHandler = \Drupal::service('module_handler');
$eck_exists = $moduleHandler
->moduleExists('eck');
if ($eck_exists) {
$entity_type = \Drupal::entityTypeManager()
->getStorage('eck_entity_type')
->load($this->entityTypeName);
if ($entity_type) {
return $entity_type
->hasTitleField();
}
}
return true;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DefaultContentEntityHandler:: |
public | function |
Overrides EntityHandlerInterface:: |
|
DefaultContentEntityHandler:: |
public | function |
Provide a list of fields that are not allowed to be pushed or pulled.
These fields typically contain all label fields that are pushed
separately anyway (we don't want to set IDs and revision IDs of entities
for example, but only use the UUID for… Overrides EntityHandlerBase:: |
|
DefaultContentEntityHandler:: |
public | function |
Overrides EntityHandlerBase:: |
|
DefaultContentEntityHandler:: |
protected | function |
Check whether the entity type supports having a label. Overrides EntityHandlerBase:: |
|
DefaultContentEntityHandler:: |
public static | function |
Check if this handler supports the given entity type. Overrides EntityHandlerInterface:: |
|
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
public | function | 2 | |
DependencySerializationTrait:: |
public | function | 2 | |
EntityHandlerBase:: |
protected | property | ||
EntityHandlerBase:: |
protected | property | ||
EntityHandlerBase:: |
protected | property | A sync instance. | |
EntityHandlerBase:: |
protected | property | A logger instance. | |
EntityHandlerBase:: |
protected | property | ||
EntityHandlerBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
EntityHandlerBase:: |
protected | function | 1 | |
EntityHandlerBase:: |
protected | function | Delete a entity. | |
EntityHandlerBase:: |
public | function |
Get the allowed pull options. Overrides EntityHandlerInterface:: |
2 |
EntityHandlerBase:: |
public | function |
Get the allowed push options. Overrides EntityHandlerInterface:: |
4 |
EntityHandlerBase:: |
protected | function | ||
EntityHandlerBase:: |
protected | function | ||
EntityHandlerBase:: |
public | function |
Get the handler settings. Overrides EntityHandlerInterface:: |
4 |
EntityHandlerBase:: |
protected | function | Get a list of fields that can't be updated. | |
EntityHandlerBase:: |
protected | function | Check if the pull should be ignored. | 2 |
EntityHandlerBase:: |
protected | function | Check if the entity should not be ignored from the push. | 2 |
EntityHandlerBase:: |
protected | function | ||
EntityHandlerBase:: |
public | function |
Pull the remote entity. Overrides EntityHandlerInterface:: |
4 |
EntityHandlerBase:: |
public | function |
Overrides EntityHandlerInterface:: |
5 |
EntityHandlerBase:: |
protected | function | Whether or not menu item references should be pushed. | |
EntityHandlerBase:: |
public | constant | 2 | |
EntityHandlerBase:: |
protected | function | 1 | |
EntityHandlerBase:: |
protected | function | ||
EntityHandlerBase:: |
protected | function | Set the values for the pulled entity. | 2 |
EntityHandlerBase:: |
protected | function | ||
EntityHandlerBase:: |
public | function |
Update the entity type definition. Overrides EntityHandlerInterface:: |
3 |
EntityHandlerBase:: |
public | constant | 2 | |
EntityHandlerBase:: |
public | constant | 5 | |
EntityHandlerBase:: |
public | function |
Validate the settings defined above. $form and $form_state are the same as
in the Form API. $settings_key is the index at $form['sync_entities'] for
this handler instance. Overrides EntityHandlerInterface:: |
|
EntityHandlerBase:: |
public | function |
Constructs a Drupal\rest\Plugin\ResourceBase object. Overrides PluginBase:: |
|
MessengerTrait:: |
protected | property | The messenger. | 27 |
MessengerTrait:: |
public | function | Gets the messenger. | 27 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
2 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 4 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |