Loading config/install/views.view.user_manuals.yml +186 −37 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ display: display_plugin: default position: 0 display_options: title: 'Related User Manuals' title: 'Related entries' fields: name: id: name Loading Loading @@ -174,8 +174,34 @@ display: cache: type: tag options: { } empty: { } empty: area_text_custom: id: area_text_custom table: views field: area_text_custom relationship: none group_type: group admin_label: '' plugin_id: text_custom empty: true content: 'There are no entries for the selected topic.' tokenize: false sorts: weight: id: weight table: taxonomy_term_field_data field: weight relationship: field_manual_topics group_type: group admin_label: '' entity_type: taxonomy_term entity_field: weight plugin_id: standard order: ASC expose: label: '' field_identifier: '' exposed: false field_manual_topics_target_id: id: field_manual_topics_target_id table: user_manual__field_manual_topics Loading Loading @@ -290,6 +316,48 @@ display: operator: '' operator_limit_selection: false operator_list: { } langcode: id: langcode table: user_manual_field_data field: langcode relationship: none group_type: group admin_label: '' entity_type: user_manual entity_field: langcode plugin_id: language operator: in value: '***LANGUAGE_language_interface***': '***LANGUAGE_language_interface***' group: 1 exposed: false expose: operator_id: '' label: '' description: '' use_operator: false operator: '' operator_limit_selection: false operator_list: { } identifier: '' required: false remember: false multiple: false remember_roles: authenticated: authenticated reduce: false is_grouped: false group_info: label: '' description: '' identifier: '' optional: true widget: select multiple: false remember: false default_group: All default_group_multiple: { } group_items: { } style: type: html_list options: Loading Loading @@ -317,7 +385,16 @@ display: distinct: false replica: false query_tags: { } relationships: { } relationships: field_manual_topics: id: field_manual_topics table: user_manual__field_manual_topics field: field_manual_topics relationship: none group_type: group admin_label: 'field_manual_topics: Taxonomy term' plugin_id: standard required: false group_by: true header: { } footer: { } Loading @@ -337,6 +414,7 @@ display: display_plugin: block position: 1 display_options: title: 'Related entries' fields: name: id: name Loading Loading @@ -465,7 +543,21 @@ display: multi_type: separator separator: ', ' field_api_classes: false empty: area_text_custom: id: area_text_custom table: views field: area_text_custom relationship: none group_type: group admin_label: '' plugin_id: text_custom empty: true content: 'There are no related entries.' tokenize: false defaults: empty: false title: false group_by: false fields: false group_by: true Loading Loading @@ -618,20 +710,6 @@ display: type: none options: offset: 0 empty: area: id: area table: views field: area relationship: none group_type: group admin_label: '' plugin_id: text empty: true content: value: '<p>There are no Documents with selected topic.</p>' format: limited_html tokenize: false arguments: { } filters: status: Loading Loading @@ -695,6 +773,48 @@ display: hierarchy: false limit: true error_message: true langcode: id: langcode table: user_manual_field_data field: langcode relationship: none group_type: group admin_label: '' entity_type: user_manual entity_field: langcode plugin_id: language operator: in value: '***LANGUAGE_language_interface***': '***LANGUAGE_language_interface***' group: 1 exposed: false expose: operator_id: '' label: '' description: '' use_operator: false operator: '' operator_limit_selection: false operator_list: { } identifier: '' required: false remember: false multiple: false remember_roles: authenticated: authenticated reduce: false is_grouped: false group_info: label: '' description: '' identifier: '' optional: true widget: select multiple: false remember: false default_group: All default_group_multiple: { } group_items: { } filter_groups: operator: AND groups: Loading @@ -719,7 +839,7 @@ display: relationship: none view_mode: teaser defaults: empty: false empty: true css_class: false use_ajax: false pager: false Loading Loading @@ -750,7 +870,7 @@ display: display_plugin: page position: 1 display_options: title: 'User Manuals' title: 'User Manual' fields: name: id: name Loading Loading @@ -883,20 +1003,6 @@ display: type: none options: offset: 0 empty: area: id: area table: views field: area relationship: none group_type: group admin_label: '' plugin_id: text empty: true content: value: '<p>There are no Documents with selected topic.</p>' format: limited_html tokenize: false arguments: { } filters: status: Loading Loading @@ -926,7 +1032,7 @@ display: exposed: true expose: operator_id: field_manual_topics_target_id_op label: 'Filter By Topics' label: 'Filter By topic' description: '' use_operator: false operator: field_manual_topics_target_id_op Loading @@ -938,9 +1044,9 @@ display: multiple: false remember_roles: authenticated: authenticated administrator: '0' anonymous: '0' content_administrator: '0' content_editor: '0' administrator: '0' reduce: false is_grouped: false group_info: Loading @@ -960,6 +1066,48 @@ display: hierarchy: false limit: true error_message: true langcode: id: langcode table: user_manual_field_data field: langcode relationship: none group_type: group admin_label: '' entity_type: user_manual entity_field: langcode plugin_id: language operator: in value: '***LANGUAGE_language_interface***': '***LANGUAGE_language_interface***' group: 1 exposed: false expose: operator_id: '' label: '' description: '' use_operator: false operator: '' operator_limit_selection: false operator_list: { } identifier: '' required: false remember: false multiple: false remember_roles: authenticated: authenticated reduce: false is_grouped: false group_info: label: '' description: '' identifier: '' optional: true widget: select multiple: false remember: false default_group: All default_group_multiple: { } group_items: { } filter_groups: operator: AND groups: Loading @@ -984,7 +1132,7 @@ display: relationship: none view_mode: teaser defaults: empty: false empty: true title: false css_class: false use_ajax: false Loading @@ -999,6 +1147,7 @@ display: css_class: '' use_ajax: true display_description: '' rendering_language: '***LANGUAGE_entity_translation***' display_extenders: { } path: admin/user-manual cache_metadata: Loading src/Entity/UserManual.php +6 −5 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ use Drupal\user\UserInterface; * @ContentEntityType( * id = "user_manual", * label = @Translation("User Manual"), * label_singular = @Translation("User Manual entry"), * label_plural = @Translation("User Manual entries"), * bundle_label = @Translation("User Manual types"), * handlers = { * "storage" = "Drupal\Core\Entity\Sql\SqlContentEntityStorage", Loading Loading @@ -181,7 +183,6 @@ class UserManual extends EditorialContentEntityBase { $fields['user_id'] = BaseFieldDefinition::create('entity_reference') ->setLabel(t('Authored by')) ->setDescription(t('The user ID of author of the User Manual entity.')) ->setRevisionable(TRUE) ->setSetting('target_type', 'user') ->setSetting('handler', 'default') Loading @@ -206,16 +207,16 @@ class UserManual extends EditorialContentEntityBase { ->setDisplayConfigurable('view', FALSE); $fields['name'] = BaseFieldDefinition::create('string') ->setLabel(t('Name')) ->setDescription(t('The name of the User Manual entity.')) ->setLabel(t('Title')) ->setRevisionable(TRUE) ->setTranslatable(TRUE) ->setSettings([ 'max_length' => 50, 'text_processing' => 0, ]) ->setDefaultValue('') ->setDisplayOptions('view', [ 'label' => 'above', 'label' => 'hidden', 'type' => 'string', 'weight' => -4, ]) Loading @@ -227,7 +228,7 @@ class UserManual extends EditorialContentEntityBase { ->setDisplayConfigurable('view', TRUE) ->setRequired(TRUE); $fields['status']->setDescription(t('A boolean indicating whether the User Manual is published.')) $fields['status'] ->setDisplayOptions('form', [ 'type' => 'boolean_checkbox', 'weight' => -3, Loading src/Form/UserManualForm.php +2 −1 Original line number Diff line number Diff line Loading @@ -36,8 +36,9 @@ class UserManualForm extends ContentEntityForm { public function buildForm(array $form, FormStateInterface $form_state) { /** @var \Drupal\user_manual\Entity\UserManual $entity */ $form = parent::buildForm($form, $form_state); $form['#title'] = $this->t('Add User Manual entry'); if (!$this->entity->isNew()) { $form['#title'] = $this->t('Edit @label User Manual entry', ['@label' => $this->entity->label()]); $form['new_revision'] = [ '#type' => 'checkbox', '#title' => $this->t('Create new revision'), Loading src/Form/UserManualTypeEntityForm.php +20 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,26 @@ class UserManualTypeEntityForm extends BundleEntityFormBase { '#description' => $this->t('Describe this user manual type.'), ]; // Provide a 'Language settings' section so that we can enable translation. // This is based on code in core node module NodeTypeForm.php. if ($this->moduleHandler->moduleExists('language')) { $form['language'] = [ '#type' => 'details', '#title' => $this->t('Language settings'), '#group' => 'additional_settings', ]; $language_configuration = ContentLanguageSettings::loadByEntityTypeBundle('user_manual', $entity_type->id()); $form['language']['language_configuration'] = [ '#type' => 'language_configuration', '#entity_information' => [ 'entity_type' => 'user_manual', 'bundle' => $entity_type->id(), ], '#default_value' => $language_configuration, ]; } return $this->protectBundleIdElement($form); } Loading tests/src/Functional/ToolbarTest.php +2 −1 Original line number Diff line number Diff line Loading @@ -69,7 +69,8 @@ class ToolbarTest extends BrowserTestBase { UserManualAccessControlHandler::VIEW_USER_MANUAL_PERMISSION, ]); $v = Vocabulary::load('manual_topics'); $test_term = $this->createTerm($v, ['name' => self::TEST_TERM_NAME]); $langcode = \Drupal::languageManager()->getCurrentLanguage()->getId(); $test_term = $this->createTerm($v, ['name' => self::TEST_TERM_NAME, 'langcode' => $langcode]); $this->testTermTid = $test_term->id(); } Loading Loading
config/install/views.view.user_manuals.yml +186 −37 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ display: display_plugin: default position: 0 display_options: title: 'Related User Manuals' title: 'Related entries' fields: name: id: name Loading Loading @@ -174,8 +174,34 @@ display: cache: type: tag options: { } empty: { } empty: area_text_custom: id: area_text_custom table: views field: area_text_custom relationship: none group_type: group admin_label: '' plugin_id: text_custom empty: true content: 'There are no entries for the selected topic.' tokenize: false sorts: weight: id: weight table: taxonomy_term_field_data field: weight relationship: field_manual_topics group_type: group admin_label: '' entity_type: taxonomy_term entity_field: weight plugin_id: standard order: ASC expose: label: '' field_identifier: '' exposed: false field_manual_topics_target_id: id: field_manual_topics_target_id table: user_manual__field_manual_topics Loading Loading @@ -290,6 +316,48 @@ display: operator: '' operator_limit_selection: false operator_list: { } langcode: id: langcode table: user_manual_field_data field: langcode relationship: none group_type: group admin_label: '' entity_type: user_manual entity_field: langcode plugin_id: language operator: in value: '***LANGUAGE_language_interface***': '***LANGUAGE_language_interface***' group: 1 exposed: false expose: operator_id: '' label: '' description: '' use_operator: false operator: '' operator_limit_selection: false operator_list: { } identifier: '' required: false remember: false multiple: false remember_roles: authenticated: authenticated reduce: false is_grouped: false group_info: label: '' description: '' identifier: '' optional: true widget: select multiple: false remember: false default_group: All default_group_multiple: { } group_items: { } style: type: html_list options: Loading Loading @@ -317,7 +385,16 @@ display: distinct: false replica: false query_tags: { } relationships: { } relationships: field_manual_topics: id: field_manual_topics table: user_manual__field_manual_topics field: field_manual_topics relationship: none group_type: group admin_label: 'field_manual_topics: Taxonomy term' plugin_id: standard required: false group_by: true header: { } footer: { } Loading @@ -337,6 +414,7 @@ display: display_plugin: block position: 1 display_options: title: 'Related entries' fields: name: id: name Loading Loading @@ -465,7 +543,21 @@ display: multi_type: separator separator: ', ' field_api_classes: false empty: area_text_custom: id: area_text_custom table: views field: area_text_custom relationship: none group_type: group admin_label: '' plugin_id: text_custom empty: true content: 'There are no related entries.' tokenize: false defaults: empty: false title: false group_by: false fields: false group_by: true Loading Loading @@ -618,20 +710,6 @@ display: type: none options: offset: 0 empty: area: id: area table: views field: area relationship: none group_type: group admin_label: '' plugin_id: text empty: true content: value: '<p>There are no Documents with selected topic.</p>' format: limited_html tokenize: false arguments: { } filters: status: Loading Loading @@ -695,6 +773,48 @@ display: hierarchy: false limit: true error_message: true langcode: id: langcode table: user_manual_field_data field: langcode relationship: none group_type: group admin_label: '' entity_type: user_manual entity_field: langcode plugin_id: language operator: in value: '***LANGUAGE_language_interface***': '***LANGUAGE_language_interface***' group: 1 exposed: false expose: operator_id: '' label: '' description: '' use_operator: false operator: '' operator_limit_selection: false operator_list: { } identifier: '' required: false remember: false multiple: false remember_roles: authenticated: authenticated reduce: false is_grouped: false group_info: label: '' description: '' identifier: '' optional: true widget: select multiple: false remember: false default_group: All default_group_multiple: { } group_items: { } filter_groups: operator: AND groups: Loading @@ -719,7 +839,7 @@ display: relationship: none view_mode: teaser defaults: empty: false empty: true css_class: false use_ajax: false pager: false Loading Loading @@ -750,7 +870,7 @@ display: display_plugin: page position: 1 display_options: title: 'User Manuals' title: 'User Manual' fields: name: id: name Loading Loading @@ -883,20 +1003,6 @@ display: type: none options: offset: 0 empty: area: id: area table: views field: area relationship: none group_type: group admin_label: '' plugin_id: text empty: true content: value: '<p>There are no Documents with selected topic.</p>' format: limited_html tokenize: false arguments: { } filters: status: Loading Loading @@ -926,7 +1032,7 @@ display: exposed: true expose: operator_id: field_manual_topics_target_id_op label: 'Filter By Topics' label: 'Filter By topic' description: '' use_operator: false operator: field_manual_topics_target_id_op Loading @@ -938,9 +1044,9 @@ display: multiple: false remember_roles: authenticated: authenticated administrator: '0' anonymous: '0' content_administrator: '0' content_editor: '0' administrator: '0' reduce: false is_grouped: false group_info: Loading @@ -960,6 +1066,48 @@ display: hierarchy: false limit: true error_message: true langcode: id: langcode table: user_manual_field_data field: langcode relationship: none group_type: group admin_label: '' entity_type: user_manual entity_field: langcode plugin_id: language operator: in value: '***LANGUAGE_language_interface***': '***LANGUAGE_language_interface***' group: 1 exposed: false expose: operator_id: '' label: '' description: '' use_operator: false operator: '' operator_limit_selection: false operator_list: { } identifier: '' required: false remember: false multiple: false remember_roles: authenticated: authenticated reduce: false is_grouped: false group_info: label: '' description: '' identifier: '' optional: true widget: select multiple: false remember: false default_group: All default_group_multiple: { } group_items: { } filter_groups: operator: AND groups: Loading @@ -984,7 +1132,7 @@ display: relationship: none view_mode: teaser defaults: empty: false empty: true title: false css_class: false use_ajax: false Loading @@ -999,6 +1147,7 @@ display: css_class: '' use_ajax: true display_description: '' rendering_language: '***LANGUAGE_entity_translation***' display_extenders: { } path: admin/user-manual cache_metadata: Loading
src/Entity/UserManual.php +6 −5 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ use Drupal\user\UserInterface; * @ContentEntityType( * id = "user_manual", * label = @Translation("User Manual"), * label_singular = @Translation("User Manual entry"), * label_plural = @Translation("User Manual entries"), * bundle_label = @Translation("User Manual types"), * handlers = { * "storage" = "Drupal\Core\Entity\Sql\SqlContentEntityStorage", Loading Loading @@ -181,7 +183,6 @@ class UserManual extends EditorialContentEntityBase { $fields['user_id'] = BaseFieldDefinition::create('entity_reference') ->setLabel(t('Authored by')) ->setDescription(t('The user ID of author of the User Manual entity.')) ->setRevisionable(TRUE) ->setSetting('target_type', 'user') ->setSetting('handler', 'default') Loading @@ -206,16 +207,16 @@ class UserManual extends EditorialContentEntityBase { ->setDisplayConfigurable('view', FALSE); $fields['name'] = BaseFieldDefinition::create('string') ->setLabel(t('Name')) ->setDescription(t('The name of the User Manual entity.')) ->setLabel(t('Title')) ->setRevisionable(TRUE) ->setTranslatable(TRUE) ->setSettings([ 'max_length' => 50, 'text_processing' => 0, ]) ->setDefaultValue('') ->setDisplayOptions('view', [ 'label' => 'above', 'label' => 'hidden', 'type' => 'string', 'weight' => -4, ]) Loading @@ -227,7 +228,7 @@ class UserManual extends EditorialContentEntityBase { ->setDisplayConfigurable('view', TRUE) ->setRequired(TRUE); $fields['status']->setDescription(t('A boolean indicating whether the User Manual is published.')) $fields['status'] ->setDisplayOptions('form', [ 'type' => 'boolean_checkbox', 'weight' => -3, Loading
src/Form/UserManualForm.php +2 −1 Original line number Diff line number Diff line Loading @@ -36,8 +36,9 @@ class UserManualForm extends ContentEntityForm { public function buildForm(array $form, FormStateInterface $form_state) { /** @var \Drupal\user_manual\Entity\UserManual $entity */ $form = parent::buildForm($form, $form_state); $form['#title'] = $this->t('Add User Manual entry'); if (!$this->entity->isNew()) { $form['#title'] = $this->t('Edit @label User Manual entry', ['@label' => $this->entity->label()]); $form['new_revision'] = [ '#type' => 'checkbox', '#title' => $this->t('Create new revision'), Loading
src/Form/UserManualTypeEntityForm.php +20 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,26 @@ class UserManualTypeEntityForm extends BundleEntityFormBase { '#description' => $this->t('Describe this user manual type.'), ]; // Provide a 'Language settings' section so that we can enable translation. // This is based on code in core node module NodeTypeForm.php. if ($this->moduleHandler->moduleExists('language')) { $form['language'] = [ '#type' => 'details', '#title' => $this->t('Language settings'), '#group' => 'additional_settings', ]; $language_configuration = ContentLanguageSettings::loadByEntityTypeBundle('user_manual', $entity_type->id()); $form['language']['language_configuration'] = [ '#type' => 'language_configuration', '#entity_information' => [ 'entity_type' => 'user_manual', 'bundle' => $entity_type->id(), ], '#default_value' => $language_configuration, ]; } return $this->protectBundleIdElement($form); } Loading
tests/src/Functional/ToolbarTest.php +2 −1 Original line number Diff line number Diff line Loading @@ -69,7 +69,8 @@ class ToolbarTest extends BrowserTestBase { UserManualAccessControlHandler::VIEW_USER_MANUAL_PERMISSION, ]); $v = Vocabulary::load('manual_topics'); $test_term = $this->createTerm($v, ['name' => self::TEST_TERM_NAME]); $langcode = \Drupal::languageManager()->getCurrentLanguage()->getId(); $test_term = $this->createTerm($v, ['name' => self::TEST_TERM_NAME, 'langcode' => $langcode]); $this->testTermTid = $test_term->id(); } Loading