Skip to content
Snippets Groups Projects
Commit d476f99c authored by Jess Straatmann's avatar Jess Straatmann
Browse files

Issue #3514451 by jastraat: Provide default strings for template types

parent 74cd9792
No related branches found
No related tags found
1 merge request!56Issue #3514451: Make sure template type labels aren't null
Pipeline #462723 passed
......@@ -149,8 +149,8 @@ class ChooseSectionFromLibraryController implements ContainerInjectionInterface
];
// Use configured labels.
$sectionLabel = $this->config->get('section_label');
$templateLabel = $this->config->get('template_label');
$sectionLabel = $this->config->get('section_label') ?? 'Section';
$templateLabel = $this->config->get('template_label') ?? 'Template';
$template_types = [
'any' => $this->t('- Any -'),
'section' => $sectionLabel,
......
......@@ -155,8 +155,8 @@ class AddSectionToLibraryForm extends ContentEntityForm {
if (isset($form['actions']['submit'])) {
// Use configured labels.
$sectionLabel = strtolower($this->config->get('section_label'));
$templateLabel = strtolower($this->config->get('template_label'));
$sectionLabel = strtolower($this->config->get('section_label') ?? 'section');
$templateLabel = strtolower($this->config->get('template_label') ?? 'template');
if ($this->templateType === 'template') {
$form['actions']['submit']['#value'] = $this->t('Add :templateLabel', [':templateLabel' => $templateLabel]);
}
......@@ -240,7 +240,7 @@ class AddSectionToLibraryForm extends ContentEntityForm {
* Title to use for the route.
*/
public function titleCallback(string $template_type = 'section'): string {
$label = $this->config->get($template_type . '_label');
$label = $this->config->get($template_type . '_label') ?? 'Section';
return $this->t('Add %type to Library', ['%type' => $label]);
}
......
......@@ -25,8 +25,8 @@ class SectionLibraryRender implements TrustedCallbackInterface {
if (isset($elements['layout_builder'])) {
$sections = $elements['layout_builder'];
$config = \Drupal::config('section_library.settings');
$section_label = strtolower($config->get('section_label'));
$template_label = strtolower($config->get('template_label'));
$section_label = strtolower($config->get('section_label') ?? 'section');
$template_label = strtolower($config->get('template_label') ?? 'template');
$url_options = [
'attributes' => [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment