// Allow modules to react on text format deletion.
\Drupal::moduleHandler()->invokeAll('filter_format_disable', [$this]);
// Clear the filter cache whenever a text format is disabled.
filter_formats_reset();
return$this; }
/**
* {@inheritdoc}
*/ publicfunctionpreSave(EntityStorageInterface $storage){ // Ensure the filters have been sorted before saving.
$this->filters()->sort();
// Create a new text format that does not escape HTML, and grant the user
// access to it.
$this->drupalLogin($this->adminUser); $edit = [ 'format' => mb_strtolower($this->randomMachineName()), 'name' => $this->randomMachineName(), ]; $this->drupalGet('admin/config/content/formats/add'); $this->submitForm($edit, 'Save configuration'); filter_formats_reset(); $format = FilterFormat::load($edit['format']); $format_id = $format->id(); $permission = $format->getPermissionName(); $roles = $this->webUser->getRoles(); $rid = $roles[0]; user_role_grant_permissions($rid, [$permission]); $this->drupalLogin($this->webUser);
// Display edition form.
// We should now have a 'text format' selector.
$this->drupalGet('entity_test/manage/' . $id . '/edit');