kgaut/kgaut_tools

Drupal 8 的工具和服务

安装次数: 8,284

依赖者: 0

建议者: 0

安全: 0

星星: 1

关注者: 2

分支: 1

开放问题: 1

类型:drupal-module

2.0.23 2024-09-05 16:00 UTC

README

安装

composer require kgaut/kgaut_tools

功能

CleanString 服务

将字符串转换为小写并移除特殊字符。

$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 服务

允许导入指定语言的字符串翻译。

用法示例

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

在上传过程中创建图像衍生物

灵感来源于 @flocondetoile 的帖子: http://flocondetoile.fr/blog/generate-programmatically-image-styles-drupal-8

为所有模板添加新的有用变量

  • basepath : Drupal basepath() 的值(不一定总是可用)
  • pathtotheme : 活跃主题的路径
  • pathtotfiles : 公共文件目录的路径

用户模板建议

基于视图模式为用户实体添加模板建议,例如:user--compact.html.twig