Skip to content

Commit

Permalink
Merge branch '1.x' of https://github.com/craftcms/generator into 2.x
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
brandonkelly committed Jun 19, 2024
2 parents 93d2a26 + 3427ee7 commit 4ccc624
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Release Notes for Craft Generator

## 2.1.0 - 2024-06-19
- Generated plugins and modules now call `$this->attachEventHandlers()` directly from `init()`, and clarify when `onInit()` should be used.

## 2.0.1 - 2024-03-08
- Generated field types, utilities, and widget types now provide default icons.
- Fixed an error that occurred when generating a utility. ([#34](https://github.com/craftcms/generator/issues/34))
Expand All @@ -8,6 +11,9 @@
- Craft Generator now requires Craft 5.
- Renamed `craft\generator\Command\EVENT_REGISTER_GENERATOR_TYPES` to `EVENT_REGISTER_GENERATORS`.

## 1.8.0 - 2024-06-19
- Generated plugins and modules now call `$this->attachEventHandlers()` directly from `init()`, and clarify when `onInit()` should be used.

## 1.7.0 - 2024-03-06
- Added the behavior generator. ([#27](https://github.com/craftcms/generator/pull/27))
- Generator now prompts for new modules’ names. ([#28](https://github.com/craftcms/generator/pull/28))
Expand Down
6 changes: 4 additions & 2 deletions src/generators/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,11 @@ private function methods(): array
parent::init();
// Defer most setup tasks until Craft is fully initialized
\$this->attachEventHandlers();
// Any code that creates an element query or loads Twig should be deferred until
// after Craft is fully initialized, to avoid conflicts with other plugins/modules
Craft::\$app->onInit(function() {
\$this->attachEventHandlers();
// ...
});
PHP,
Expand Down
6 changes: 4 additions & 2 deletions src/generators/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -719,9 +719,11 @@ private function pluginMethods(): array
'init' => <<<PHP
parent::init();
// Defer most setup tasks until Craft is fully initialized
\$this->attachEventHandlers();
// Any code that creates an element query or loads Twig should be deferred until
// after Craft is fully initialized, to avoid conflicts with other plugins/modules
Craft::\$app->onInit(function() {
\$this->attachEventHandlers();
// ...
});
PHP,
Expand Down

0 comments on commit 4ccc624

Please sign in to comment.