class FilterFormatEditor in Acquia Content Hub 8.2
Handles FilterFormatEditor entity saves to apply related schema.
Hierarchy
- class \Drupal\acquia_contenthub\EventSubscriber\EntityImport\FilterFormatEditor implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of FilterFormatEditor
1 string reference to 'FilterFormatEditor'
1 service uses FilterFormatEditor
File
- src/
EventSubscriber/ EntityImport/ FilterFormatEditor.php, line 14
Namespace
Drupal\acquia_contenthub\EventSubscriber\EntityImportView source
class FilterFormatEditor implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[AcquiaContentHubEvents::ENTITY_IMPORT_NEW][] = 'onImportNew';
$events[AcquiaContentHubEvents::ENTITY_IMPORT_UPDATE][] = 'onImportNew';
return $events;
}
/**
* Ensures an editor exists for a filter format.
*
* @param \Drupal\acquia_contenthub\Event\EntityImportEvent $event
* The entity import event.
*
* @throws \Drupal\Core\Entity\EntityStorageException
*/
public function onImportNew(EntityImportEvent $event) {
if (!\Drupal::moduleHandler()
->moduleExists('editor')) {
return;
}
$filter_format = $event
->getEntity();
// Early return if this isn't the class of entity we care about.
if (!$filter_format instanceof FilterFormat) {
return;
}
if (editor_load($filter_format
->id())) {
return;
}
$values = [
'editor' => 'ckeditor',
'format' => $filter_format
->id(),
];
$editor = Editor::create($values);
$editor
->save();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FilterFormatEditor:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
FilterFormatEditor:: |
public | function | Ensures an editor exists for a filter format. |