Skip to content

Commit ab9a12a

Browse files
authored
Refactor conflicting modules notification (#785)
* refactored ConflictingModulesNotification * removed unused constant
1 parent ace5d4f commit ab9a12a

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

app/code/Meta/BusinessExtension/Model/System/Message/ConflictingModulesNotification.php

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,16 @@ class ConflictingModulesNotification implements MessageInterface
2727
/**
2828
* @var string
2929
*/
30-
private static string $meta_business_extension = 'Meta_BusinessExtension';
30+
private string $conflictingModuleFound = '';
3131

3232
/**
33-
* @var string
34-
*/
35-
private string $conflictingModulesFound = '';
36-
37-
/**
38-
* ConflictingModulesNotification constructor.
33+
* Constructor
3934
*
4035
* @param MetaIssueNotification $metaIssueNotification
4136
* @param ModuleManager $moduleManager
4237
*/
4338
public function __construct(
44-
MetaIssueNotification $metaIssueNotification,
39+
MetaIssueNotification $metaIssueNotification,
4540
ModuleManager $moduleManager
4641
) {
4742
$this->metaIssueNotification = $metaIssueNotification;
@@ -51,7 +46,7 @@ public function __construct(
5146
/**
5247
* Get identity
5348
*
54-
* @return string
49+
* @return mixed|string
5550
*/
5651
public function getIdentity()
5752
{
@@ -60,19 +55,16 @@ public function getIdentity()
6055
}
6156

6257
/**
63-
* Validate if any conflicting modules are found
58+
* Toggle flag for displaying notification
6459
*
6560
* @return bool
6661
*/
67-
public function isDisplayed()
62+
public function isDisplayed(): bool
6863
{
69-
//find out if the user enabled the Meta Business Extension
70-
$has_Meta_BusinessExtension = $this->moduleManager->isEnabled(self::$meta_business_extension);
71-
72-
//iterate through the user's module manager to see if they have any conflicting modules
64+
// iterate through the user's module manager to see if they have any conflicting modules
7365
foreach (self::$conflictingModules as $conflictingModule) {
74-
if ($this->moduleManager->isEnabled($conflictingModule) && $has_Meta_BusinessExtension) {
75-
$this->conflictingModulesFound = $conflictingModule;
66+
if ($this->moduleManager->isEnabled($conflictingModule)) {
67+
$this->conflictingModuleFound = $conflictingModule;
7668
return true;
7769
}
7870
}
@@ -84,18 +76,18 @@ public function isDisplayed()
8476
*
8577
* @return string
8678
*/
87-
public function getText()
79+
public function getText(): string
8880
{
8981
return sprintf('The following module conflicts with the Facebook & Instagram Extension: [%s].
90-
Please disable the conflicting module.', $this->conflictingModulesFound);
82+
Please disable the conflicting module.', $this->conflictingModuleFound);
9183
}
9284

9385
/**
94-
* Get severity
86+
* Get severity of the notification
9587
*
9688
* @return int
9789
*/
98-
public function getSeverity()
90+
public function getSeverity(): int
9991
{
10092
return self::SEVERITY_CRITICAL;
10193
}

0 commit comments

Comments
 (0)