diff --git a/core/modules/filter/lib/Drupal/filter/FilterFormatFormControllerBase.php b/core/modules/filter/lib/Drupal/filter/FilterFormatFormControllerBase.php index cfb0aee..0602ad8 100644 --- a/core/modules/filter/lib/Drupal/filter/FilterFormatFormControllerBase.php +++ b/core/modules/filter/lib/Drupal/filter/FilterFormatFormControllerBase.php @@ -7,12 +7,38 @@ namespace Drupal\filter; +use Drupal\Core\Config\ConfigFactory; +use Drupal\Core\Entity\EntityControllerInterface; use Drupal\Core\Entity\EntityFormController; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Provides a base form controller for a filter format. */ -abstract class FilterFormatFormControllerBase extends EntityFormController { +abstract class FilterFormatFormControllerBase extends EntityFormController implements EntityControllerInterface { + + /** + * The config factory. + * + * @var \Drupal\Core\Config\ConfigFactory + */ + protected $configFactory; + + /** + * Constructs a new FilterFormatFormControllerBase. + */ + public function __construct(ConfigFactory $config_factory) { + $this->configFactory = $config_factory; + } + + /** + * {@inheritdoc} + */ + public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { + return new static( + $container->get('config.factory') + ); + } /** * {@inheritdoc} @@ -48,7 +74,7 @@ public function form(array $form, array &$form_state) { $form['roles'] = array( '#type' => 'checkboxes', '#title' => t('Roles'), - '#options' => array_map('check_plain', user_role_names()), + '#options' => array_map('\Drupal\Component\Utility\String::checkPlain', user_role_names()), '#disabled' => $is_fallback, '#weight' => -10, ); @@ -59,7 +85,7 @@ public function form(array $form, array &$form_state) { // If editing an existing text format, pre-select its current permissions. $form['roles']['#default_value'] = array_keys(filter_get_roles_by_format($format)); } - elseif ($admin_role = config('user.settings')->get('admin_role')) { + elseif ($admin_role = $this->configFactory->get('user.settings')->get('admin_role')) { // If adding a new text format and the site has an administrative role, // pre-select that role so as to grant administrators access to the new // text format permission by default. diff --git a/core/modules/filter/lib/Drupal/filter/FilterFormatListController.php b/core/modules/filter/lib/Drupal/filter/FilterFormatListController.php index 75da0d5..b39887e 100644 --- a/core/modules/filter/lib/Drupal/filter/FilterFormatListController.php +++ b/core/modules/filter/lib/Drupal/filter/FilterFormatListController.php @@ -7,8 +7,13 @@ namespace Drupal\filter; +use Drupal\Component\Utility\String; +use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Config\Entity\ConfigEntityListController; +use Drupal\Core\Entity\EntityStorageControllerInterface; +use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Defines the filter format list controller. @@ -23,6 +28,35 @@ class FilterFormatListController extends ConfigEntityListController implements F protected $entities; /** + * The config factory service. + * + * @var \Drupal\Core\Config\ConfigFactory + */ + protected $configFactory; + + /** + * {@inheritdoc} + */ + public function __construct($entity_type, array $entity_info, EntityStorageControllerInterface $storage, ModuleHandlerInterface $module_handler, ConfigFactory $config_factory) { + parent::__construct($entity_type, $entity_info, $storage, $module_handler); + + $this->configFactory = $config_factory; + } + + /** + * {@inheritdoc} + */ + public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { + return new static( + $entity_type, + $entity_info, + $container->get('plugin.manager.entity')->getStorageController($entity_type), + $container->get('module_handler'), + $container->get('config.factory') + ); + } + + /** * {@inheritdoc} */ public function getFormID() { @@ -62,6 +96,7 @@ public function buildForm(array $form, array &$form_state) { array('order', 'sibling', 'text-format-order-weight'), ), ); + $fallback_choice = $this->configFactory->get('filter.settings')->get('always_show_fallback_choice'); foreach ($this->entities as $id => $format) { $form['formats'][$id]['#attributes']['class'][] = 'draggable'; $form['formats'][$id]['#weight'] = $format->weight; @@ -75,17 +110,17 @@ public function buildForm(array $form, array &$form_state) { // to all roles and cannot be disabled via the admin interface. $form['formats'][$id]['#is_fallback'] = ($id == $fallback_format); if ($form['formats'][$id]['#is_fallback']) { - $form['formats'][$id]['name'] = array('#markup' => drupal_placeholder($format->name)); - if (config('filter.settings')->get('always_show_fallback_choice')) { - $roles_markup = drupal_placeholder(t('All roles may use this format')); + $form['formats'][$id]['name'] = array('#markup' => String::placeholder($format->name)); + if ($fallback_choice) { + $roles_markup = String::placeholder(t('All roles may use this format')); } else { - $roles_markup = drupal_placeholder(t('This format is shown when no other formats are available')); + $roles_markup = String::placeholder(t('This format is shown when no other formats are available')); } } else { - $form['formats'][$id]['name'] = array('#markup' => check_plain($format->name)); - $roles = array_map('check_plain', filter_get_roles_by_format($format)); + $form['formats'][$id]['name'] = array('#markup' => String::checkPlain($format->name)); + $roles = array_map('\Drupal\Component\Utility\String::checkPlain', filter_get_roles_by_format($format)); $roles_markup = $roles ? implode(', ', $roles) : t('No roles may use this format'); $links['disable'] = array( 'title' => t('disable'),