Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions kgaut_tools.module
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,14 @@ function kgaut_tools_entity_insert(EntityInterface $entity) {
* Add custom variable to all templates.
*/
function kgaut_tools_preprocess(&$variables, $hook) {
$pathResolver = \Drupal::service('extension.path.resolver');
$isHttps = \Drupal::request()->isSecure() || \Drupal::service('settings')->get('force_https');
$variables['basepath'] = base_path();
$variables['baseurl_front'] = Url::fromRoute('<front>', [], ['absolute' => TRUE, 'https' => $isHttps])->toString();
$variables['pathtotheme'] = base_path() . drupal_get_path('theme', \Drupal::theme()->getActiveTheme()->getName());
$variables['path_default_theme'] = base_path() . drupal_get_path('theme', \Drupal::config('system.theme')->get('default'));
$variables['baseurl_theme'] = $variables['baseurl_front'] . drupal_get_path('theme', \Drupal::theme()->getActiveTheme()->getName());
$variables['baseurl_default_theme'] = $variables['baseurl_front'] . drupal_get_path('theme', \Drupal::config('system.theme')->get('default'));
$variables['pathtotheme'] = base_path() . $pathResolver->getPath('theme', \Drupal::theme()->getActiveTheme()->getName());
$variables['path_default_theme'] = base_path() . $pathResolver->getPath('theme', \Drupal::config('system.theme')->get('default'));
$variables['baseurl_theme'] = $variables['baseurl_front'] . $pathResolver->getPath('theme', \Drupal::theme()->getActiveTheme()->getName());
$variables['baseurl_default_theme'] = $variables['baseurl_front'] . $pathResolver->getPath('theme', \Drupal::config('system.theme')->get('default'));
$variables['pathtotfiles'] = PublicStream::basePath();
$variables['baseurl_files'] = $variables['baseurl_front'] . PublicStream::basePath();
}
Expand All @@ -93,8 +94,10 @@ function kgaut_tools_form_system_performance_settings_alter(&$form, \Drupal\Core
* Add custom variables to DrupalSettings.
*/
function kgaut_tools_page_attachments(array &$attachments) {
$pathResolver = \Drupal::service('extension.path.resolver');

$attachments['#attached']['drupalSettings']['basepath'] = base_path();
$attachments['#attached']['drupalSettings']['pathtotheme'] = base_path() . drupal_get_path('theme', \Drupal::theme()->getActiveTheme()->getName());
$attachments['#attached']['drupalSettings']['pathtotheme'] = base_path() . $pathResolver->getPath('theme', \Drupal::theme()->getActiveTheme()->getName());
$attachments['#attached']['drupalSettings']['pathtotfiles'] = PublicStream::basePath();
}

Expand Down Expand Up @@ -166,5 +169,5 @@ function kgaut_tools_theme_suggestions_page(array $variables) {
function kgaut_tools_user_login($account) {
$event = new \Drupal\kgaut_tools\Event\UserLoginEvent($account);
$event_dispatcher = \Drupal::service('event_dispatcher');
$event_dispatcher->dispatch($event::EVENT_NAME, $event);
$event_dispatcher->dispatch($event, $event::EVENT_NAME);
}
2 changes: 1 addition & 1 deletion src/Event/UserLoginEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Drupal\kgaut_tools\Event;

use Drupal\user\UserInterface;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;

/**
* Event that is fired when a user logs in.
Expand Down
2 changes: 0 additions & 2 deletions src/TranslationImporter.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php

namespace Drupal\kgaut_tools;
use Drupal\clearblue\Services\ClearblueLanguageManager;
use Drupal\Core\Language\Language;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\locale\StringStorageInterface;

Expand Down