Skip to content
Snippets Groups Projects
Commit d7f368c7 authored by Sagar Ramgade's avatar Sagar Ramgade Committed by Jeff Landfried
Browse files

Issue #3308569 by Sagar Ramgade, jlandfried, Andy Inman: Add URL aliases to entities

parent 9b9edc5e
Branches
Tags
1 merge request!16Issue #3308569: Add URL aliases to entities
......@@ -234,6 +234,19 @@ class UserManual extends EditorialContentEntityBase {
'weight' => -3,
]);
if (\Drupal::moduleHandler()->moduleExists('path')) {
$fields['path'] = BaseFieldDefinition::create('path')
->setCustomStorage(TRUE)
->setLabel(t('URL alias'))
->setTranslatable(TRUE)
->setComputed(TRUE)
->setDisplayOptions('form', [
'type' => 'path',
'weight' => 100,
])
->setDisplayConfigurable('form', TRUE);
}
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Created'))
->setDescription(t('The time that the entity was created.'));
......
......@@ -52,7 +52,7 @@ class UserManualForm extends ContentEntityForm {
'#title' => $this->t('Publishing Information'),
'#open' => TRUE,
'#tree' => FALSE,
'#weight' => 100,
'#weight' => 11,
];
if (isset($form['new_revision'])) {
......
......@@ -5,6 +5,8 @@
* User Manual module file.
*/
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\Core\Link;
......@@ -160,7 +162,8 @@ function user_manual_add_default_fields($user_manual_type_id) {
'teaser' => [
'display_label' => 'hidden',
'display_type' => 'text_summary_or_trimmed'
]
],
'weight' => 5,
],
'field_manual_topics' => [
'label' => 'Topics',
......@@ -182,6 +185,7 @@ function user_manual_add_default_fields($user_manual_type_id) {
],
],
],
'weight' => 6,
]
];
......@@ -218,7 +222,8 @@ function user_manual_add_default_fields($user_manual_type_id) {
$display_repository->getFormDisplay('user_manual', $user_manual_type_id)
->setComponent($field_key, [
'type' => $field_data['type'],
'settings' => $field_data['form_settings']
'settings' => $field_data['form_settings'],
'weight' => $field_data['weight'],
])->save();
// Assign display settings for default view mode.
......@@ -240,3 +245,4 @@ function user_manual_add_default_fields($user_manual_type_id) {
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment