View source
<?php
use Drupal\filter\Entity\FilterFormat;
use Drupal\field\Entity\FieldConfig;
function hashtags_install() {
FilterFormat::load('full_html')
->setFilterConfig('filter_hashtags', [
'status' => TRUE,
'weight' => 10,
])
->save();
FilterFormat::load('basic_html')
->setFilterConfig('filter_hashtags', [
'status' => TRUE,
'weight' => 10,
])
->save();
filter_formats_reset();
}
function hashtags_uninstall() {
$hashtags_field_name = \Drupal::config('hashtags.settings')
->get('hashtags_taxonomy_terms_field_name');
$entity_types = _hashtags_get_content_entity_types();
foreach ($entity_types as $entity_type) {
$bundles = \Drupal::service('entity.manager')
->getBundleInfo($entity_type);
foreach ($bundles as $bundle => $bundle_info) {
if (_hashtags_is_field_exists($entity_type, $bundle, $hashtags_field_name)) {
$hashtags_field = FieldConfig::loadByName($entity_type, $bundle, $hashtags_field_name);
if (!empty($hashtags_field)) {
$hashtags_field
->delete();
}
$activated_text_fields = _hashtags_get_activated_text_fields($entity_type, $bundle);
foreach ($activated_text_fields as $field_name) {
$text_field = \Drupal::entityTypeManager()
->getStorage('field_config')
->load("{$entity_type}.{$bundle}.{$field_name}");
if (!empty($text_field)) {
$text_field
->unsetThirdPartySetting('hashtags', 'hashtags_activate');
$text_field
->save();
}
}
}
}
}
}