Skip to content

Commit

Permalink
Merge pull request #3518 from craftcms/defer-init
Browse files Browse the repository at this point in the history
Update Plugin.php
  • Loading branch information
nfourtythree committed May 23, 2024
2 parents 06d37ba + 8e0fa2e commit c53d42f
Showing 1 changed file with 36 additions and 34 deletions.
70 changes: 36 additions & 34 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,40 +234,42 @@ public static function editions(): array
public function init(): void
{
parent::init();
$request = Craft::$app->getRequest();

$this->_addTwigExtensions();
$this->_registerFieldTypes();
$this->_registerPermissions();
$this->_registerCraftEventListeners();
$this->_registerProjectConfigEventListeners();
$this->_registerVariables();
$this->_registerForeignKeysRestore();
$this->_registerPoweredByHeader();
$this->_registerElementTypes();
$this->_registerGqlInterfaces();
$this->_registerGqlQueries();
$this->_registerGqlComponents();
$this->_registerGqlEagerLoadableFields();
$this->_registerCacheTypes();
$this->_registerGarbageCollection();
$this->_registerDebugPanels();

if ($request->getIsConsoleRequest()) {
$this->_defineResaveCommand();
} elseif ($request->getIsCpRequest()) {
$this->_registerCpRoutes();
$this->_registerStoreAddressAuthHandlers();
$this->_registerWidgets();
$this->_registerElementExports();
$this->_defineFieldLayoutElements();
$this->_registerTemplateHooks();
$this->_registerRedactorLinkOptions();
$this->_registerCKEditorLinkOptions();
} else {
$this->_registerSiteRoutes();
}


Craft::$app->onInit(function() {
$request = Craft::$app->getRequest();

$this->_addTwigExtensions();
$this->_registerFieldTypes();
$this->_registerPermissions();
$this->_registerCraftEventListeners();
$this->_registerProjectConfigEventListeners();
$this->_registerVariables();
$this->_registerForeignKeysRestore();
$this->_registerPoweredByHeader();
$this->_registerElementTypes();
$this->_registerGqlInterfaces();
$this->_registerGqlQueries();
$this->_registerGqlComponents();
$this->_registerGqlEagerLoadableFields();
$this->_registerCacheTypes();
$this->_registerGarbageCollection();
$this->_registerDebugPanels();

if ($request->getIsConsoleRequest()) {
$this->_defineResaveCommand();
} elseif ($request->getIsCpRequest()) {
$this->_registerCpRoutes();
$this->_registerStoreAddressAuthHandlers();
$this->_registerWidgets();
$this->_registerElementExports();
$this->_defineFieldLayoutElements();
$this->_registerTemplateHooks();
$this->_registerRedactorLinkOptions();
$this->_registerCKEditorLinkOptions();
} else {
$this->_registerSiteRoutes();
}
});
Craft::setAlias('@commerceLib', Craft::getAlias('@craft/commerce/../lib'));
}

Expand Down

0 comments on commit c53d42f

Please sign in to comment.