diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index 9af423f..2f3c2ba 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -296,8 +296,7 @@ function filter_format_disable($format) { * @see filter_format_load() */ function filter_format_exists($format_id) { - $formats = entity_load_multiple('filter_format'); - return !empty($formats[$format_id]); + return entity_load('filter_format', $format_id); } /** diff --git a/core/modules/filter/lib/Drupal/filter/FilterFormatStorageController.php b/core/modules/filter/lib/Drupal/filter/FilterFormatStorageController.php new file mode 100644 index 0000000..74c22be --- /dev/null +++ b/core/modules/filter/lib/Drupal/filter/FilterFormatStorageController.php @@ -0,0 +1,86 @@ +name = trim($entity->name); + $entity->cache = _filter_format_is_cacheable($entity); + if (!isset($entity->status)) { + $entity->status = 1; + } + if (!isset($entity->weight)) { + $entity->weight = 0; + } + + // Programmatic saves may not contain any filters. + if (!isset($entity->filters)) { + $entity->filters = array(); + } + $filter_info = filter_get_filters(); + foreach ($filter_info as $name => $filter) { + // If the format does not specify an explicit weight for a filter, assign + // a default weight, either defined in hook_filter_info(), or the default of + // 0 by filter_get_filters(). + if (!isset($entity->filters[$name]['weight'])) { + $entity->filters[$name]['weight'] = $filter['weight']; + } + $entity->filters[$name]['status'] = isset($entity->filters[$name]['status']) ? $entity->filters[$name]['status'] : 0; + $entity->filters[$name]['module'] = $filter['module']; + + // If settings were passed, only ensure default settings. + if (isset($entity->filters[$name]['settings'])) { + if (isset($filter['default settings'])) { + $entity->filters[$name]['settings'] = array_merge($filter['default settings'], $entity->filters[$name]['settings']); + } + } + // Otherwise, use default settings or fall back to an empty array. + else { + $entity->filters[$name]['settings'] = isset($filter['default settings']) ? $filter['default settings'] : array(); + } + + // Sort filters properties by key, to minimize diff issues. + ksort($entity->filters[$name]); + } + + // Sort filters by enabled/disabled first then by weight + @uasort($entity->filters, '_filter_format_filter_cmp'); + } + + /** + * Overrides \Drupal\Core\Config\Entity\ConfigStorageController::postSave(). + */ + protected function postSave(EntityInterface $entity, $update) { + if ($update == SAVED_UPDATED) { + // Clear the filter cache whenever a text format is updated. + cache('filter')->deleteTags(array('filter_format' => $entity->format)); + } + + filter_formats_reset(); + + if (!empty($entity->status)) { + // Save user permissions. + if ($permission = filter_permission_name($entity)) { + foreach ($entity->roles as $rid => $enabled) { + user_role_change_permissions($rid, array($permission => $enabled)); + } + } + } + } + +} diff --git a/core/modules/filter/lib/Drupal/filter/Plugin/Core/Entity/FilterFormat.php b/core/modules/filter/lib/Drupal/filter/Plugin/Core/Entity/FilterFormat.php index b1e8a8f..f6a546a 100644 --- a/core/modules/filter/lib/Drupal/filter/Plugin/Core/Entity/FilterFormat.php +++ b/core/modules/filter/lib/Drupal/filter/Plugin/Core/Entity/FilterFormat.php @@ -18,7 +18,7 @@ * id = "filter_format", * label = @Translation("Filter Format"), * module = "filter", - * controller_class = "Drupal\Core\Config\Entity\ConfigStorageController", + * controller_class = "Drupal\filter\FilterFormatStorageController", * config_prefix = "filter.format", * entity_keys = { * "id" = "format", @@ -92,76 +92,10 @@ class FilterFormat extends ConfigEntityBase { public $filters = array(); /** - * Implements Drupal\Core\Entity\EntityInterface::id(). + * Implements \Drupal\Core\Entity\EntityInterface::id(). */ public function id() { return $this->format; } - /** - * Implements Drupal\Core\Entity\EntityInterface::save(). - */ - public function save() { - $this->name = trim($this->name); - $this->cache = _filter_format_is_cacheable($this); - if (!isset($this->status)) { - $this->status = 1; - } - if (!isset($this->weight)) { - $this->weight = 0; - } - - // Programmatic saves may not contain any filters. - if (!isset($this->filters)) { - $this->filters = array(); - } - $filter_info = filter_get_filters(); - foreach ($filter_info as $name => $filter) { - // If the format does not specify an explicit weight for a filter, assign - // a default weight, either defined in hook_filter_info(), or the default of - // 0 by filter_get_filters(). - if (!isset($this->filters[$name]['weight'])) { - $this->filters[$name]['weight'] = $filter['weight']; - } - $this->filters[$name]['status'] = isset($this->filters[$name]['status']) ? $this->filters[$name]['status'] : 0; - $this->filters[$name]['module'] = $filter['module']; - - // If settings were passed, only ensure default settings. - if (isset($this->filters[$name]['settings'])) { - if (isset($filter['default settings'])) { - $this->filters[$name]['settings'] = array_merge($filter['default settings'], $this->filters[$name]['settings']); - } - } - // Otherwise, use default settings or fall back to an empty array. - else { - $this->filters[$name]['settings'] = isset($filter['default settings']) ? $filter['default settings'] : array(); - } - - // Sort filters properties by key, to minimize diff issues. - ksort($this->filters[$name]); - } - - // Sort filters by enabled/disabled first then by weight - @uasort($this->filters, '_filter_format_filter_cmp'); - - $return = parent::save(); - - if ($return == SAVED_UPDATED) { - // Clear the filter cache whenever a text format is updated. - cache('filter')->deleteTags(array('filter_format' => $this->format)); - } - - filter_formats_reset(); - - if (!empty($this->status)) { - // Save user permissions. - if ($permission = filter_permission_name($this)) { - foreach ($this->roles as $rid => $enabled) { - user_role_change_permissions($rid, array($permission => $enabled)); - } - } - } - - return $return; - } } diff --git a/core/modules/taxonomy/taxonomy.install b/core/modules/taxonomy/taxonomy.install index de8711a..68ea1a6 100644 --- a/core/modules/taxonomy/taxonomy.install +++ b/core/modules/taxonomy/taxonomy.install @@ -71,7 +71,7 @@ function taxonomy_schema() { 'type' => 'varchar', 'length' => 255, 'not null' => FALSE, - 'description' => 'The Filter Format id of the description.', + 'description' => 'The filter format of the description.', ), 'weight' => array( 'type' => 'int',