kgaut/kgaut_tools

Tools and services for drupal 8

Installs: 8 687

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 1

Open Issues: 1

Type:drupal-module

2.0.23 2024-09-05 16:00 UTC

README

Installation

composer require kgaut/kgaut_tools

Features

CleanString Service

Transliterate and remove special char from a string.

$mystring = "Hello World";
// 'hello-world'
$cleanString = \Drupal::service('kgaut_tools.stringcleaner')->clean($categorie->name); 
//'hello_world'
$cleanStringWithoutDash = \Drupal::service('kgaut_tools.stringcleaner')->clean($categorie->name,true); 

TranslationImporter Service

Allow to import translation for a given string with a given language.

Usage example :

$translationImporter = \Drupal::service('kgaut_tools.translation_importer');
$translationImporter->importTranslation("I love drupal", 'fr', "J'aime drupal");

Create image derivates during upload

Inspired by @flocondetoile's post : http://flocondetoile.fr/blog/generate-programmatically-image-styles-drupal-8

Add new useful var to all templates :

  • basepath : Drupal basepath() value (not always available)
  • pathtotheme : path to active theme
  • pathtotfiles : path to public files directory

User templates suggestions :

Add templates suggestions for user entity based on the view mode ie : user--compact.html.twig