chi-teck / field_definition_dumper
该包已被弃用且不再维护。未建议替代包。
提供 Drush 命令以转储 Drupal 字段、小部件和格式化程序的定义。
1.1.0
2023-03-15 04:10 UTC
Requires
- php: >=8.1
- drush/drush: ^11 || ^12
This package is auto-updated.
Last update: 2023-05-01 00:14:59 UTC
README
过时:这些命令已移动到 Drush 核心 (drush-ops/drush#5517).
字段定义转储器
Drush 命令用于转储 Drupal 字段、小部件和格式化程序的定义。
Drupal 中的字段显示选项没有很好地记录。当字段在代码中定义时,这使得很难找到它们的正确值。例如,当您指定自定义实体类型的基字段定义时。
$fields['uid'] = BaseFieldDefinition::create('entity_reference') ->setLabel(t('Authored by')) ->setSetting('target_type', 'user') ->setDisplayOptions('form', [ 'type' => 'entity_reference_autocomplete', 'settings' => [ 'match_operator' => 'CONTAINS', 'size' => '30', 'placeholder' => '', ], ]) ->setDisplayOptions('view', [ 'label' => 'hidden', 'type' => 'author', ]);
另一个用例是以特定的格式化程序和设置渲染字段。
$display_options = [ 'type' => 'entity_reference_label', 'settings' => ['link' => FALSE], ]; $build = $node->uid->view($display_options);
{# Assuming Twig Tweak module is installed #} {% set display_options = { type: 'entity_reference_label', settings: {link: false} } %} {{ node.uid|view(display_options) }}
这些 Drush 命令将帮助您在源代码中的小部件和格式化程序中搜索适当的选项。
安装
composer require chi-teck/field_definition_dumper --dev
drush en field_definition_dumper
由于该模块旨在用于本地开发,建议您通过在本地 settings.php 文件中添加以下行来将其排除在配置之外。
$settings['config_exclude_modules'] = ['field_definition_dumper'];
用法
drush field:dump:types --help
drush field:dump:widgets --help
drush field:dump:formatters --help
许可证
GNU 通用公共许可证,版本 2 或更高版本。