Skip to content

Releases: Chi-teck/drupal-code-generator

3.5.0

11 Apr 14:25
74c2dc6
Compare
Choose a tag to compare
  • Added revision UI for generated revisionable entity type.
  • Fixed config entity form template not using entity class.
  • Fixed a warning about SDC component properties that require schema changes if a non-scalar type is used.
  • Fixed generation revision_metadata_keys for revisioable entity types.

3.4.0

10 Mar 13:54
Compare
Choose a tag to compare
  • Plugin manager using attributes for plugins #122
  • SingleDirectoryComponent::__construct should type against interface #125
  • Declare support for Drupal core ^10 || ^11 in new modules #126

Added support for Drupal 10.3

3.3.0

22 Oct 05:00
56da920
Compare
Choose a tag to compare

Added PhpStorm meta data for KernelTestBase methods
Minor bugfixes and improvements

3.2.0

06 Aug 11:20
Compare
Choose a tag to compare

Provided a generator for single directory components (#109)

3.1.0

24 Jun 14:26
Compare
Choose a tag to compare
  • Add interactive interviewer for permissions.yml generator #106
  • Update drupal/coder requirement from 8.3.18 to 8.3.20 #105
  • generate entity:content adds wrong permissions #102
  • FileSystemInterface::prepareDirectory expects a bitmask as argument #100
  • Add "drush generate readme" command #99

Multiple minor bug-fixes and improvements.

3.0.0

26 Mar 07:16
Compare
Choose a tag to compare

Release Notes

New API for generators

DCG 3 generators are not API compatible with DCG 2, however porting them to DCG 3 is quite simple.

Example of DCG 3 generator

#[Generator(
  name: 'controller',
  description: 'Generates a controller',
  templatePath: __DIR__,
  type: GeneratorType::MODULE_COMPONENT,
)]
final class Controller extends BaseGenerator {

  /**
   * {@inheritdoc}
   */
  protected function generate(array &$vars, Assets $assets): void {
    $ir = $this->createInterviewer($vars);

    $vars['machine_name'] = $ir->askMachineName();
    $vars['name'] = $ir->askName();
    $vars['class'] = $ir->askClass(default: '{machine_name|camelize}Controller');

    $vars['services'] = $ir->askServices(FALSE);

    $assets->addFile('src/Controller/{class}.php', 'controller.twig');
  }

}

Key differences from DCG 2 generator:

  1. Generator metadata is defined through PHP attributes.
  2. Most interaction logic has been moved to a separate service called "interviewer".
  3. All generators, regardless of their type, directly extend the BaseGenerator class.

Updated requirements

DCG 3 requires PHP 8.1+, symfony/console 6, twig/twig 3.

Revised generators

DCG 2 generators often created a sort of working examples, not just code templates. That has been changed in DCG 3.
The generated code is now just a boilerplate, it typically does not perform any useful actions without customization. If
you are looking for examples check out the Examples module.

Removed generators

The following generators have been removed:

  • yml:theme-info
  • yml:module-info
  • theme:file
  • misc:project
  • misc:html-page
  • module-file
  • console:drupal-console-command
  • console:drush-command
  • misc:d7:* (all Drupal 7 generators)

Those generators had little value and were rarely used.

Improved PhpStorm metadata generator

The phpstorm-meta generator can now provide PhpStorm with way more information about the project. It's recommended to add this command to your local deployment process and exclude the .phpstorm.meta.php directory from version control using the .gitignore file.

Event system

DCG 3 dispatches events that modules can subscribe to.
Currently, the following events are available:

  1. Application - allows to alter DCG application
  2. Generator Info - allows to register new generators
  3. Generator Info Alter - allows to alter registered generators
  4. Asset Preprocess - allows to modify generated code

Note that using Drush services is still recommended way to register generators in the Drush application.

3.0.0-RC1

29 Jan 16:09
Compare
Choose a tag to compare
Add service dumper script

2.6.2

14 Jan 09:38
22ed1cc
Compare
Choose a tag to compare

Fixed wrong file name for post_udpate_NAME hook (#93)

2.6.0

15 Sep 09:07
Compare
Choose a tag to compare

Added phpstorm metadata for ContainerInterface #89
Minor bug fixes

2.5.2

30 Mar 16:07
90f6a87
Compare
Choose a tag to compare

Allow symfony console 6 and psr log 3 #83