Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Niklan committed Nov 7, 2024
1 parent a8149c0 commit 845d573
Show file tree
Hide file tree
Showing 21 changed files with 317 additions and 375 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static function create(ContainerInterface $container): self {
private function prepareBrandingVariables(array &$variables): void {
$cache = CacheableMetadata::createFromRenderArray($variables);

$site_settings = $this->configFactory->getEditable('system.site');
$site_settings = $this->configFactory->get('system.site');
$cache->addCacheableDependency($site_settings);

$logo_path = $this->themeManager->getActiveTheme()->getPath() . '/logo.svg';
Expand Down
10 changes: 5 additions & 5 deletions app/Drupal/niklan/niklan.routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ niklan.about:
niklan.about.settings:
path: '/admin/niklan/about'
defaults:
_title_callback: '\Drupal\niklan\Form\AboutSettingsForm::title'
_form: '\Drupal\niklan\Form\AboutSettingsForm'
_title: 'About settings'
_form: '\Drupal\niklan\Form\Settings\AboutSettingsForm'
requirements:
_permission: 'administer site configuration'

Expand All @@ -26,23 +26,23 @@ niklan.support.settings:
path: '/admin/niklan/support'
defaults:
_title: 'Support settings'
_form: '\Drupal\niklan\Form\SupportSettingsForm'
_form: '\Drupal\niklan\Form\Settings\SupportSettingsForm'
requirements:
_permission: 'administer site configuration'

niklan.contact.settings:
path: '/admin/niklan/contact'
defaults:
_title: 'Contact settings'
_form: '\Drupal\niklan\Form\ContactSettingsForm'
_form: '\Drupal\niklan\Form\Settings\ContactSettingsForm'
requirements:
_permission: 'administer site configuration'

niklan.services.settings:
path: '/admin/niklan/services'
defaults:
_title: 'Services settings'
_form: '\Drupal\niklan\Form\ServicesSettingsForm'
_form: '\Drupal\niklan\Form\Settings\ServicesSettingsForm'
requirements:
_permission: 'administer site configuration'

Expand Down
8 changes: 4 additions & 4 deletions app/Drupal/niklan/niklan.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ services:
Drupal\niklan\Utility\DatabaseTagUsageStatistics: {}
Drupal\niklan\Contract\Utility\TagUsageStatistics: '@Drupal\niklan\Utility\DatabaseTagUsageStatistics'

Drupal\niklan\Factory\KeyValue\ServiceContainerLanguageAwareFactory: {}
keyvalue.language_aware: '@Drupal\niklan\Factory\KeyValue\ServiceContainerLanguageAwareFactory'
Drupal\niklan\Factory\KeyValue\DatabaseLanguageAwareFactory: {}
keyvalue.language_aware.database: '@Drupal\niklan\Factory\KeyValue\DatabaseLanguageAwareFactory'
Drupal\niklan\Repository\KeyValue\ServiceContainerLanguageAwareFactory: {}
keyvalue.language_aware: '@Drupal\niklan\Repository\KeyValue\ServiceContainerLanguageAwareFactory'
Drupal\niklan\Repository\KeyValue\DatabaseLanguageAwareFactory: {}
keyvalue.language_aware.database: '@Drupal\niklan\Repository\KeyValue\DatabaseLanguageAwareFactory'

Drupal\niklan\EventSubscriber\LanguageAwareSettingsRoutes:
tags:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

declare(strict_types=1);

namespace Drupal\niklan\Contract\Factory\KeyValue;
namespace Drupal\niklan\Contract\Repository\KeyValue;

use Drupal\Core\KeyValueStore\KeyValueFactoryInterface;
use Drupal\niklan\Contract\Repository\KeyValue\LanguageAwareStore;

/**
* Defines an interface for language-aware key/value stores.
Expand Down
4 changes: 4 additions & 0 deletions app/Drupal/niklan/src/Controller/BlogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Render\RendererInterface;
use Drupal\node\NodeInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
Expand All @@ -17,13 +18,15 @@ final class BlogController implements ContainerInjectionInterface {
public function __construct(
protected EntityTypeManagerInterface $entityTypeManager,
protected RendererInterface $renderer,
protected LanguageManagerInterface $languageManager,
) {}

#[\Override]
public static function create(ContainerInterface $container): self {
return new self(
$container->get('entity_type.manager'),
$container->get('renderer'),
$container->get(LanguageManagerInterface::class),
);
}

Expand Down Expand Up @@ -99,6 +102,7 @@ protected function getEntityIds(): array {
->accessCheck(FALSE)
->condition('type', 'blog_entry')
->condition('status', NodeInterface::PUBLISHED)
->condition('langcode', $this->languageManager->getCurrentLanguage()->getId(), '=')
->sort('created', 'DESC');

if ($this->limit) {
Expand Down
5 changes: 2 additions & 3 deletions app/Drupal/niklan/src/Controller/ContactController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\niklan\Repository\AboutSettings;
use Drupal\niklan\Repository\ContactSettings;
use Drupal\niklan\Repository\KeyValue\ContactSettings;
use Symfony\Component\DependencyInjection\ContainerInterface;

final readonly class ContactController implements ContainerInjectionInterface {
Expand All @@ -29,7 +28,7 @@ public function __invoke(): array {
'#description' => [
'#type' => 'processed_text',
'#text' => $this->settings->getDescription(),
'#format' => AboutSettings::TEXT_FORMAT,
'#format' => $this->settings::TEXT_FORMAT,
],
'#email' => $this->settings->getEmail(),
'#telegram' => $this->settings->getTelegram(),
Expand Down
5 changes: 2 additions & 3 deletions app/Drupal/niklan/src/Controller/ServicesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\niklan\Repository\AboutSettings;
use Drupal\niklan\Repository\ServicesSettings;
use Drupal\niklan\Repository\KeyValue\ServicesSettings;
use Symfony\Component\DependencyInjection\ContainerInterface;

final readonly class ServicesController implements ContainerInjectionInterface {
Expand All @@ -29,7 +28,7 @@ public function __invoke(): array {
'#description' => [
'#type' => 'processed_text',
'#text' => $this->settings->getDescription(),
'#format' => AboutSettings::TEXT_FORMAT,
'#format' => $this->settings::TEXT_FORMAT,
],
'#hourly_rate' => $this->settings->getHourlyRate(),
];
Expand Down
4 changes: 2 additions & 2 deletions app/Drupal/niklan/src/Controller/SupportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\niklan\Repository\SupportSettings;
use Drupal\niklan\Repository\KeyValue\SupportSettings;
use Symfony\Component\DependencyInjection\ContainerInterface;

final readonly class SupportController implements ContainerInjectionInterface {
Expand All @@ -28,7 +28,7 @@ public function __invoke(): array {
'#description' => [
'#type' => 'processed_text',
'#text' => $this->settings->getDescription(),
'#format' => SupportSettings::TEXT_FORMAT,
'#format' => $this->settings::TEXT_FORMAT,
],
'#donate_url' => $this->settings->getDonateUrl(),
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

public const array ROUTES_TO_ENHANCE = [
'niklan.about.settings',
'niklan.contact.settings',
'niklan.services.settings',
'niklan.support.settings',
];

public function __construct(
Expand Down
101 changes: 0 additions & 101 deletions app/Drupal/niklan/src/Form/ContactSettingsForm.php

This file was deleted.

94 changes: 0 additions & 94 deletions app/Drupal/niklan/src/Form/ServicesSettingsForm.php

This file was deleted.

Loading

0 comments on commit 845d573

Please sign in to comment.