DefaultMediaHandler.php in CMS Content Sync 8
File
src/Plugin/cms_content_sync/entity_handler/DefaultMediaHandler.php
View source
<?php
namespace Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handler;
use Drupal\cms_content_sync\Plugin\EntityHandlerBase;
use Drupal\cms_content_sync\PushIntent;
use Drupal\Core\Entity\EntityInterface;
class DefaultMediaHandler extends EntityHandlerBase {
public const USER_PROPERTY = 'uid';
public const USER_REVISION_PROPERTY = 'revision_user';
public const REVISION_TRANSLATION_AFFECTED_PROPERTY = 'revision_translation_affected';
public static function supports($entity_type, $bundle) {
return 'media' == $entity_type;
}
public function push(PushIntent $intent, EntityInterface $entity = null) {
if (!parent::push($intent, $entity)) {
return false;
}
if (!$entity) {
$entity = $intent
->getEntity();
}
$intent
->setProperty('created', intval($entity
->getCreatedTime()));
return true;
}
public function getForbiddenFields() {
return array_merge(parent::getForbiddenFields(), [
'thumbnail',
]);
}
public function getAllowedPreviewOptions() {
return [
'table' => 'Table',
'preview_mode' => 'Preview mode',
];
}
}
Classes
Name |
Description |
DefaultMediaHandler |
Class DefaultMediaHandler, providing a minimalistic implementation for the
media entity type. |