You are here

README.txt in Devel 8.2

Same filename in this branch
  1. 8.2 README.txt
  2. 8.2 devel_generate/README.txt
  3. 8.2 kint/README.txt
Same filename and directory in other branches
  1. 8 devel_generate/README.txt
This module creates the "DevelGenerate" plugin type.

All you need to do to provide a new instance for "DevelGenerate" plugin type
is to create your class extending "DevelGenerateBase" and following the next steps.

1 - Declaring your plugin with annotations:

/**
 * Provides a ExampleDevelGenerate plugin.
 *
 * @DevelGenerate(
 *   id = "example",
 *   label = @Translation("example"),
 *   description = @Translation("Generate a given number of example elements. Optionally delete current example elements."),
 *   url = "example",
 *   permission = "administer example",
 *   settings = {
 *     "num" = 50,
 *     "kill" = FALSE,
 *     "another_property" = "default_value"
 *   }
 * )
 */

2 - Implement "settingsForm" method to create a form using the properties from annotations.

3 - Implement "handleDrushParams" method. It should return an array of values.

4 - Implement "generateElements" method. You can write here your business logic
using the array of values.

Notes:

You can alter existing properties for every plugin implementing hook_devel_generate_info_alter.

DevelGenerateBaseInterface details base wrapping methods that most DevelGenerate implementations
will want to directly inherit from Drupal\devel_generate\DevelGenerateBase.

To give support for a new field type the field type base class should properly
implements \Drupal\Core\Field\FieldItemInterface::generateSampleValue().
Devel Generate automatically uses the values returned by this method during the
generate process for generate placeholder field values. For more information
see:
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Field%21FieldItemInterface.php/function/FieldItemInterface::generateSampleValue

File

devel_generate/README.txt
View source
  1. This module creates the "DevelGenerate" plugin type.
  2. All you need to do to provide a new instance for "DevelGenerate" plugin type
  3. is to create your class extending "DevelGenerateBase" and following the next steps.
  4. 1 - Declaring your plugin with annotations:
  5. /**
  6. * Provides a ExampleDevelGenerate plugin.
  7. *
  8. * @DevelGenerate(
  9. * id = "example",
  10. * label = @Translation("example"),
  11. * description = @Translation("Generate a given number of example elements. Optionally delete current example elements."),
  12. * url = "example",
  13. * permission = "administer example",
  14. * settings = {
  15. * "num" = 50,
  16. * "kill" = FALSE,
  17. * "another_property" = "default_value"
  18. * }
  19. * )
  20. */
  21. 2 - Implement "settingsForm" method to create a form using the properties from annotations.
  22. 3 - Implement "handleDrushParams" method. It should return an array of values.
  23. 4 - Implement "generateElements" method. You can write here your business logic
  24. using the array of values.
  25. Notes:
  26. You can alter existing properties for every plugin implementing hook_devel_generate_info_alter.
  27. DevelGenerateBaseInterface details base wrapping methods that most DevelGenerate implementations
  28. will want to directly inherit from Drupal\devel_generate\DevelGenerateBase.
  29. To give support for a new field type the field type base class should properly
  30. implements \Drupal\Core\Field\FieldItemInterface::generateSampleValue().
  31. Devel Generate automatically uses the values returned by this method during the
  32. generate process for generate placeholder field values. For more information
  33. see:
  34. https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Field%21FieldItemInterface.php/function/FieldItemInterface::generateSampleValue