kgaut / kgaut_tools
Drupal 8 的工具和服务
2.0.23
2024-09-05 16:00 UTC
Requires
- drupal/pathauto: *
Suggests
- drupal/block_field: *
- drupal/paragraphs: *
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