Skip to content

Commit

Permalink
[generate:plugin:fieldwidget] Add schema file (#4116)
Browse files Browse the repository at this point in the history
* [generate:plugin:fieldwidget] Add schema file

* [generate:plugin:fieldwidget] Add annotation module name
  • Loading branch information
hjuarez20 authored and enzolutions committed Jul 29, 2019
1 parent 57931ca commit 8f81264
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Generator/PluginFieldWidgetGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,19 @@ public function generate(array $parameters)
$module = $parameters['module'];
$class_name = $parameters['class_name'];

$moduleInstance = $this->extensionManager->getModule($module);

$this->renderFile(
'module/src/Plugin/Field/FieldWidget/fieldwidget.php.twig',
$this->extensionManager->getPluginPath($module, 'Field/FieldWidget') . '/' . $class_name . '.php',
$parameters
);

$this->renderFile(
'module/schema.yml.twig',
$moduleInstance->getPath() . '/' . $module . '.schema.yml',
$parameters,
FILE_APPEND
);
}
}
10 changes: 10 additions & 0 deletions templates/module/schema.yml.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
field.widget.settings.{{ plugin_id }}:
type: mapping
label: '{{ label }} widget settings'
mapping:
size:
type: integer
label: 'Size'
placeholder:
type: textfield
label: 'Placeholder'
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use Drupal\Core\Form\FormStateInterface;
*
* @FieldWidget(
* id = "{{ plugin_id }}",
* module = "{{ module }}"
* label = @Translation("{{ label }}"){% if field_type %},
* field_types = {
* "{{ field_type }}"
Expand Down

0 comments on commit 8f81264

Please sign in to comment.