Issue #2387983 by Garrett Albright, larowlan: PluginNotFoundException when enabling module that provides text filter
parent
ab94733023
commit
f562cc9b7f
|
@ -100,8 +100,14 @@ function filter_system_info_alter(&$info, Extension $file, $type) {
|
||||||
$used_in = [];
|
$used_in = [];
|
||||||
// Find out if any filter formats have the plugin enabled.
|
// Find out if any filter formats have the plugin enabled.
|
||||||
foreach (filter_formats() as $filter_format) {
|
foreach (filter_formats() as $filter_format) {
|
||||||
foreach ($filter_plugins as $filter_plugin) {
|
$filters = $filter_format->filters();
|
||||||
if ($filter_format->filters($filter_plugin['id'])->status) {
|
// Typically, all formats will contain settings for all filter plugins,
|
||||||
|
// even if they are disabled. However, if a module which provides filter
|
||||||
|
// plugins is being enabled right now, that won't be the case, so we
|
||||||
|
// still check to see if this format has this filter before we check
|
||||||
|
// the filter status.
|
||||||
|
foreach ($filter_plugins as $filter_plugin) {
|
||||||
|
if ($filters->has($filter_plugin['id']) && $filters->get($filter_plugin['id'])->status) {
|
||||||
$used_in[] = $filter_format->label();
|
$used_in[] = $filter_format->label();
|
||||||
$info['required'] = TRUE;
|
$info['required'] = TRUE;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -71,6 +71,12 @@ class FilterFormTest extends WebTestBase {
|
||||||
public function testFilterForm() {
|
public function testFilterForm() {
|
||||||
$this->doFilterFormTestAsAdmin();
|
$this->doFilterFormTestAsAdmin();
|
||||||
$this->doFilterFormTestAsNonAdmin();
|
$this->doFilterFormTestAsNonAdmin();
|
||||||
|
// Ensure that enabling modules which provide filter plugins behaves
|
||||||
|
// correctly.
|
||||||
|
// @see https://www.drupal.org/node/2387983
|
||||||
|
\Drupal::service('module_installer')->install(['filter_test_plugin']);
|
||||||
|
// Force rebuild module data.
|
||||||
|
_system_rebuild_module_data();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
name: 'Filter test plugin'
|
||||||
|
type: module
|
||||||
|
description: 'Tests enabling of modules which provide filter plugins.'
|
||||||
|
package: Testing
|
||||||
|
version: VERSION
|
||||||
|
core: 8.x
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Contains \Drupal\filter_test_plugin\Plugin\Filter\FilterSparkles.
|
||||||
|
*
|
||||||
|
* This filter does not do anything, but enabling of its module is done in a
|
||||||
|
* test.
|
||||||
|
*
|
||||||
|
* @see \Drupal\filter\Tests\FilterFormTest::testFilterForm()
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Drupal\filter_test_plugin\Plugin\Filter;
|
||||||
|
|
||||||
|
use Drupal\filter\FilterProcessResult;
|
||||||
|
use Drupal\filter\Plugin\FilterBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a filter to limit allowed HTML tags.
|
||||||
|
*
|
||||||
|
* @Filter(
|
||||||
|
* id = "filter_sparkles",
|
||||||
|
* title = @Translation("Sparkles filter"),
|
||||||
|
* type = Drupal\filter\Plugin\FilterInterface::TYPE_HTML_RESTRICTOR,
|
||||||
|
* settings = {},
|
||||||
|
* weight = -10
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
class FilterSparkles extends FilterBase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function process($text, $langcode) {
|
||||||
|
return new FilterProcessResult($text);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue