Loading core/modules/navigation/config/install/navigation.settings.yml +7 −5 Original line number Diff line number Diff line logo_provider: default logo_managed: null logo_max_filesize: 1048576 logo_height: 40 logo_width: 40 logo: provider: default managed: null max: filesize: 1048576 height: 40 width: 40 core/modules/navigation/config/schema/navigation.schema.yml +47 −35 Original line number Diff line number Diff line Loading @@ -6,7 +6,11 @@ navigation.settings: constraints: FullyValidatable: ~ mapping: logo_provider: logo: type: mapping label: 'Logo settings' mapping: provider: type: string label: 'Select Navigation logo handling' constraints: Loading @@ -14,34 +18,42 @@ navigation.settings: - default - hide - custom logo_managed: managed: type: integer label: 'Custom logo' nullable: true constraints: Range: min: 0 logo_max_filesize: max: type: mapping label: 'Logo maximum settings' mapping: filesize: type: integer label: 'Maximum file sizes (bytes)' constraints: NotNull: [ ] Range: min: 0 logo_height: height: type: integer label: 'Logo expected height' constraints: NotNull: [ ] Range: min: 0 logo_width: width: type: integer label: 'Logo expected width' constraints: NotNull: [ ] Range: min: 0 constraints: ValidKeys: '<infer>' constraints: ValidKeys: '<infer>' navigation.block_layout: type: config_object Loading core/modules/navigation/navigation.install +19 −0 Original line number Diff line number Diff line Loading @@ -23,3 +23,22 @@ function navigation_requirements($phase) { return $requirements; } /** * Reorganizes the values for the logo settings. */ function navigation_update_11001(array &$sandbox): void { $settings = \Drupal::configFactory()->getEditable('navigation.settings'); $settings->setData([ 'logo' => [ 'provider' => $settings->get('logo_provider'), 'managed' => $settings->get('logo_managed'), 'max' => [ 'filesize' => $settings->get('logo_max_filesize'), 'height' => $settings->get('logo_height'), 'width' => $settings->get('logo_width'), ], ], ]); $settings->save(TRUE); } core/modules/navigation/src/Form/SettingsForm.php +11 −11 Original line number Diff line number Diff line Loading @@ -108,7 +108,7 @@ public function buildForm(array $form, FormStateInterface $form_state): array { NavigationRenderer::LOGO_PROVIDER_HIDE => $this->t('Hide logo'), NavigationRenderer::LOGO_PROVIDER_CUSTOM => $this->t('Custom logo'), ], '#config_target' => 'navigation.settings:logo_provider', '#config_target' => 'navigation.settings:logo.provider', ]; $form['logo']['image'] = [ '#type' => 'container', Loading @@ -119,8 +119,8 @@ public function buildForm(array $form, FormStateInterface $form_state): array { ], ]; $allowed = 'png jpg jpeg'; $current_logo_managed_fid = $config->get('logo_managed') ? [$config->get('logo_managed')] : NULL; $max_navigation_allowed = $config->get('logo_max_filesize'); $current_logo_managed_fid = $config->get('logo.managed') ? [$config->get('logo.managed')] : NULL; $max_navigation_allowed = $config->get('logo.max.filesize'); $max_system_allowed = Environment::getUploadMaxSize(); $max_allowed = $max_navigation_allowed < $max_system_allowed ? $max_navigation_allowed : $max_system_allowed; $upload_validators = [ Loading Loading @@ -166,8 +166,8 @@ public function submitForm(array &$form, FormStateInterface $form_state): void { $config = $this->config('navigation.settings'); // Get the previous config settings. $previous_logo_provider = $config->get('logo_provider'); $previous_logo_fid = $config->get('logo_managed'); $previous_logo_provider = $config->get('logo.provider'); $previous_logo_fid = $config->get('logo.managed'); // Get new values from the form. $new_logo_provider = $form_state->getValue('logo_provider'); Loading Loading @@ -195,7 +195,7 @@ public function submitForm(array &$form, FormStateInterface $form_state): void { } $config ->set('logo_managed', $new_logo_fid) ->set('logo.managed', $new_logo_fid) ->save(); parent::submitForm($form, $form_state); } Loading @@ -215,12 +215,12 @@ protected function validateLogoManaged(array $form, FormStateInterface $form_sta return; } $width = $config->get('logo_width'); $height = $config->get('logo_height'); $width = $config->get('logo.max.width'); $height = $config->get('logo.max.height'); // Skip if the fid has not been modified. $fid = reset($logo_managed); if ($fid == $config->get('logo_managed')) { if ($fid == $config->get('logo.managed')) { return; } Loading Loading @@ -251,8 +251,8 @@ protected function adjustLogoDimensions(File $file): bool { return FALSE; } $width = $config->get('logo_width'); $height = $config->get('logo_height'); $width = $config->get('logo.max.width'); $height = $config->get('logo.max.height'); if ($image->getWidth() <= $width && $image->getHeight() <= $height) { return TRUE; Loading core/modules/navigation/src/NavigationRenderer.php +2 −2 Original line number Diff line number Diff line Loading @@ -101,7 +101,7 @@ public function removeToolbar(array &$page_top): void { */ public function buildNavigation(array &$page_top): void { $logo_settings = $this->configFactory->get('navigation.settings'); $logo_provider = $logo_settings->get('logo_provider'); $logo_provider = $logo_settings->get('logo.provider'); $cacheability = new CacheableMetadata(); $contexts = [ Loading Loading @@ -144,7 +144,7 @@ public function buildNavigation(array &$page_top): void { $page_top['navigation'] = $build; if ($logo_provider === self::LOGO_PROVIDER_CUSTOM) { $logo_managed = File::load($logo_settings->get('logo_managed')); $logo_managed = File::load($logo_settings->get('logo.managed')); if ($logo_managed instanceof FileInterface) { $logo_managed_uri = $logo_managed->getFileUri(); $logo_managed_url = $this->fileUrlGenerator->generateAbsoluteString($logo_managed_uri); Loading Loading
core/modules/navigation/config/install/navigation.settings.yml +7 −5 Original line number Diff line number Diff line logo_provider: default logo_managed: null logo_max_filesize: 1048576 logo_height: 40 logo_width: 40 logo: provider: default managed: null max: filesize: 1048576 height: 40 width: 40
core/modules/navigation/config/schema/navigation.schema.yml +47 −35 Original line number Diff line number Diff line Loading @@ -6,7 +6,11 @@ navigation.settings: constraints: FullyValidatable: ~ mapping: logo_provider: logo: type: mapping label: 'Logo settings' mapping: provider: type: string label: 'Select Navigation logo handling' constraints: Loading @@ -14,34 +18,42 @@ navigation.settings: - default - hide - custom logo_managed: managed: type: integer label: 'Custom logo' nullable: true constraints: Range: min: 0 logo_max_filesize: max: type: mapping label: 'Logo maximum settings' mapping: filesize: type: integer label: 'Maximum file sizes (bytes)' constraints: NotNull: [ ] Range: min: 0 logo_height: height: type: integer label: 'Logo expected height' constraints: NotNull: [ ] Range: min: 0 logo_width: width: type: integer label: 'Logo expected width' constraints: NotNull: [ ] Range: min: 0 constraints: ValidKeys: '<infer>' constraints: ValidKeys: '<infer>' navigation.block_layout: type: config_object Loading
core/modules/navigation/navigation.install +19 −0 Original line number Diff line number Diff line Loading @@ -23,3 +23,22 @@ function navigation_requirements($phase) { return $requirements; } /** * Reorganizes the values for the logo settings. */ function navigation_update_11001(array &$sandbox): void { $settings = \Drupal::configFactory()->getEditable('navigation.settings'); $settings->setData([ 'logo' => [ 'provider' => $settings->get('logo_provider'), 'managed' => $settings->get('logo_managed'), 'max' => [ 'filesize' => $settings->get('logo_max_filesize'), 'height' => $settings->get('logo_height'), 'width' => $settings->get('logo_width'), ], ], ]); $settings->save(TRUE); }
core/modules/navigation/src/Form/SettingsForm.php +11 −11 Original line number Diff line number Diff line Loading @@ -108,7 +108,7 @@ public function buildForm(array $form, FormStateInterface $form_state): array { NavigationRenderer::LOGO_PROVIDER_HIDE => $this->t('Hide logo'), NavigationRenderer::LOGO_PROVIDER_CUSTOM => $this->t('Custom logo'), ], '#config_target' => 'navigation.settings:logo_provider', '#config_target' => 'navigation.settings:logo.provider', ]; $form['logo']['image'] = [ '#type' => 'container', Loading @@ -119,8 +119,8 @@ public function buildForm(array $form, FormStateInterface $form_state): array { ], ]; $allowed = 'png jpg jpeg'; $current_logo_managed_fid = $config->get('logo_managed') ? [$config->get('logo_managed')] : NULL; $max_navigation_allowed = $config->get('logo_max_filesize'); $current_logo_managed_fid = $config->get('logo.managed') ? [$config->get('logo.managed')] : NULL; $max_navigation_allowed = $config->get('logo.max.filesize'); $max_system_allowed = Environment::getUploadMaxSize(); $max_allowed = $max_navigation_allowed < $max_system_allowed ? $max_navigation_allowed : $max_system_allowed; $upload_validators = [ Loading Loading @@ -166,8 +166,8 @@ public function submitForm(array &$form, FormStateInterface $form_state): void { $config = $this->config('navigation.settings'); // Get the previous config settings. $previous_logo_provider = $config->get('logo_provider'); $previous_logo_fid = $config->get('logo_managed'); $previous_logo_provider = $config->get('logo.provider'); $previous_logo_fid = $config->get('logo.managed'); // Get new values from the form. $new_logo_provider = $form_state->getValue('logo_provider'); Loading Loading @@ -195,7 +195,7 @@ public function submitForm(array &$form, FormStateInterface $form_state): void { } $config ->set('logo_managed', $new_logo_fid) ->set('logo.managed', $new_logo_fid) ->save(); parent::submitForm($form, $form_state); } Loading @@ -215,12 +215,12 @@ protected function validateLogoManaged(array $form, FormStateInterface $form_sta return; } $width = $config->get('logo_width'); $height = $config->get('logo_height'); $width = $config->get('logo.max.width'); $height = $config->get('logo.max.height'); // Skip if the fid has not been modified. $fid = reset($logo_managed); if ($fid == $config->get('logo_managed')) { if ($fid == $config->get('logo.managed')) { return; } Loading Loading @@ -251,8 +251,8 @@ protected function adjustLogoDimensions(File $file): bool { return FALSE; } $width = $config->get('logo_width'); $height = $config->get('logo_height'); $width = $config->get('logo.max.width'); $height = $config->get('logo.max.height'); if ($image->getWidth() <= $width && $image->getHeight() <= $height) { return TRUE; Loading
core/modules/navigation/src/NavigationRenderer.php +2 −2 Original line number Diff line number Diff line Loading @@ -101,7 +101,7 @@ public function removeToolbar(array &$page_top): void { */ public function buildNavigation(array &$page_top): void { $logo_settings = $this->configFactory->get('navigation.settings'); $logo_provider = $logo_settings->get('logo_provider'); $logo_provider = $logo_settings->get('logo.provider'); $cacheability = new CacheableMetadata(); $contexts = [ Loading Loading @@ -144,7 +144,7 @@ public function buildNavigation(array &$page_top): void { $page_top['navigation'] = $build; if ($logo_provider === self::LOGO_PROVIDER_CUSTOM) { $logo_managed = File::load($logo_settings->get('logo_managed')); $logo_managed = File::load($logo_settings->get('logo.managed')); if ($logo_managed instanceof FileInterface) { $logo_managed_uri = $logo_managed->getFileUri(); $logo_managed_url = $this->fileUrlGenerator->generateAbsoluteString($logo_managed_uri); Loading