Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.x] Additional Generators #3235

Draft
wants to merge 7 commits into
base: 4.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"codeception/module-yii2": "^1.0.0",
"craftcms/ckeditor": "^3.0",
"craftcms/ecs": "dev-main",
"craftcms/generator": "^1.5",
"craftcms/phpstan": "dev-main",
"craftcms/rector": "dev-main",
"craftcms/redactor": "*",
Expand Down
217 changes: 216 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
use craft\commerce\fieldlayoutelements\VariantTitleField;
use craft\commerce\fields\Products as ProductsField;
use craft\commerce\fields\Variants as VariantsField;
use craft\commerce\generators\Adjuster;
use craft\commerce\generators\Gateway as GatewayGenerator;
use craft\commerce\generators\ShippingMethod;
use craft\commerce\gql\interfaces\elements\Product as GqlProductInterface;
use craft\commerce\gql\interfaces\elements\Variant as GqlVariantInterface;
use craft\commerce\gql\queries\Product as GqlProductQueries;
Expand Down Expand Up @@ -114,6 +117,7 @@
use craft\events\RegisterGqlTypesEvent;
use craft\events\RegisterUserPermissionsEvent;
use craft\fixfks\controllers\RestoreController;
use craft\generator\Command;
use craft\gql\ElementQueryConditionBuilder;
use craft\helpers\Console;
use craft\helpers\Db;
Expand Down Expand Up @@ -254,6 +258,7 @@ public function init(): void
$this->_registerCacheTypes();
$this->_registerGarbageCollection();
$this->_registerDebugPanels();
$this->_registerGenerators();

if ($request->getIsConsoleRequest()) {
$this->_defineResaveCommand();
Expand Down Expand Up @@ -1029,4 +1034,20 @@ private function _registerTemplateHooks(): void
Craft::$app->getView()->hook('cp.users.edit.content', [$this->getCustomers(), 'addEditUserCommerceTabContent']);
}
}

/**
* Registers custom generators for Commerce components.
*
* @since 4.3
*/
private function _registerGenerators(): void
{
if (class_exists(Command::class)) {
Event::on(Command::class, Command::EVENT_REGISTER_GENERATOR_TYPES, function(RegisterComponentTypesEvent $event) {
$event->types[] = Adjuster::class;
$event->types[] = GatewayGenerator::class;
$event->types[] = ShippingMethod::class;
});
}
}
}
Loading