Skip to content
Snippets Groups Projects
Commit 592cbd45 authored by Scott Euser's avatar Scott Euser
Browse files

Move description update hook to install file, update field description, minor coding standards

parent d7cbd463
No related branches found
No related merge requests found
......@@ -5,6 +5,8 @@
* Contains install and update hooks.
*/
use Drupal\Core\Field\BaseFieldDefinition;
/**
* Implements hook_install().
*/
......@@ -182,3 +184,29 @@ function site_settings_update_8007() {
$config->save();
}
}
/**
* Add description column to the site settings table.
*/
function site_settings_update_10003(&$sandbox) {
$field_storage_definition = BaseFieldDefinition::create('string')
->setLabel(t('Description'))
->setDescription(t('Administrative description of the Site Setting(s). This description is not shown to the visitor.'))
->setSettings([
'max_length' => 255,
'text_processing' => 0,
])
->setDefaultValue('')
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'string',
])
->setDisplayOptions('form', [
'type' => 'string_textfield',
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
\Drupal::entityDefinitionUpdateManager()
->installFieldStorageDefinition('description', 'site_setting_entity', 'site_setting_entity', $field_storage_definition);
}
\ No newline at end of file
......@@ -5,7 +5,6 @@
* Contains site_settings.module..
*/
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Routing\RouteMatchInterface;
/**
......@@ -92,29 +91,3 @@ function _site_settings_replicate_finish_batch($success, $results, $operations)
$replicator = \Drupal::service('site_settings.replicator');
$replicator->finishBatch($success, $results, $operations);
}
/**
* Implements hook_update_N().
*/
function site_settings_update_10003(&$sandbox) {
$field_storage_definition = BaseFieldDefinition::create('string')
->setLabel(t('Description'))
->setDescription(t('Description of the Site Settings.'))
->setSettings([
'max_length' => 255,
'text_processing' => 0,
])
->setDefaultValue('')
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'string',
])
->setDisplayOptions('form', [
'type' => 'string_textfield',
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
\Drupal::entityDefinitionUpdateManager()
->installFieldStorageDefinition('description', 'site_setting_entity', 'site_setting_entity', $field_storage_definition);
}
......@@ -301,7 +301,7 @@ class SiteSettingEntity extends ContentEntityBase implements SiteSettingEntityIn
$fields['description'] = BaseFieldDefinition::create('string')
->setLabel(t('Description'))
->setDescription(t('Description of the Site Settings.'))
->setDescription(t('Administrative description of the Site Setting(s). This description is not shown to the visitor.'))
->setSettings([
'max_length' => 255,
'text_processing' => 0,
......
......@@ -87,9 +87,10 @@ interface SiteSettingEntityInterface extends ContentEntityInterface, EntityChang
* Gets the Site Setting description.
*
* @param string $description
* The description of the site setting.
*
* @return \Drupal\site_settings\SiteSettingEntityInterface
* The called Site Setting entity.
* The called Site Setting entity.
*/
public function setDescription($description);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment