Skip to content

Commit

Permalink
Split plugin enabled/disabled into own classes
Browse files Browse the repository at this point in the history
  • Loading branch information
convenient committed Aug 4, 2023
1 parent 775010d commit a37b279
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public function testClassPluginsOnDeletedClass()
$this->assertEmpty($infos, 'We should have no info level items');
$this->assertNotEmpty($warnings, 'We should have a warning');
$expectedWarnings = [
'Plugin' => [
'Plugin Disabled' => [
'Some_Plugin_Class_On_Delete_Target::beforeGetUpdatedAt',
'Some_Plugin_Class_On_Delete_Target::afterGetUpdatedAt',
'Some_Plugin_Class_On_Delete_Target::aroundGetUpdatedAt',
Expand Down Expand Up @@ -243,7 +243,7 @@ public function testClassPluginsOnCreatedClass()
$this->assertEmpty($infos, 'We should have no info level items');
$this->assertNotEmpty($warnings, 'We should have a warning');
$expectedWarnings = [
'Plugin' => [
'Plugin Enabled' => [
'Some_Plugin_Class_On_Created_Target::beforeGetUpdatedAt',
'Some_Plugin_Class_On_Created_Target::afterGetUpdatedAt',
'Some_Plugin_Class_On_Created_Target::aroundGetUpdatedAt',
Expand Down
4 changes: 4 additions & 0 deletions src/Ampersand/PatchHelper/Checks.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class Checks
public const TYPE_PREFERENCE_REMOVED = 'Preference Removed';
public const TYPE_PREFERENCE = 'Preference';
public const TYPE_METHOD_PLUGIN = 'Plugin';
public const TYPE_METHOD_PLUGIN_DISABLED = 'Plugin Disabled';
public const TYPE_METHOD_PLUGIN_ENABLED = 'Plugin Enabled';
public const TYPE_DB_SCHEMA_ADDED = 'DB schema added';
public const TYPE_DB_SCHEMA_CHANGED = 'DB schema changed';
public const TYPE_DB_SCHEMA_REMOVED = 'DB schema removed';
Expand Down Expand Up @@ -41,5 +43,7 @@ class Checks
self::TYPE_SETUP_PATCH_SCHEMA,
self::TYPE_SETUP_SCRIPT,
self::TYPE_METHOD_PLUGIN,
self::TYPE_METHOD_PLUGIN_DISABLED,
self::TYPE_METHOD_PLUGIN_ENABLED,
];
}
5 changes: 2 additions & 3 deletions src/Ampersand/PatchHelper/Checks/ClassPluginPhp.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,12 @@ class_exists($areaConfig[$area][$pluginClass]['type'])
continue;
}
if (isset($targetClassMethods) && is_array($targetClassMethods) && !empty($targetClassMethods)) {
// created handling
if (isset($targetClassMethods[$methodName])) {
$this->warnings[Checks::TYPE_METHOD_PLUGIN][] = "$nonMagentoPlugin::$method";
$this->warnings[Checks::TYPE_METHOD_PLUGIN_ENABLED][] = "$nonMagentoPlugin::$method";
}
} else {
// deleted handling
$this->warnings[Checks::TYPE_METHOD_PLUGIN][] = "$nonMagentoPlugin::$method";
$this->warnings[Checks::TYPE_METHOD_PLUGIN_DISABLED][] = "$nonMagentoPlugin::$method";
}
}
}
Expand Down

0 comments on commit a37b279

Please sign in to comment.