Skip to content

Commit 34dfa4e

Browse files
committed
System Message for Modules Conflicting with Meta Extension
1 parent 3a40e6a commit 34dfa4e

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
3+
4+
namespace Meta\BusinessExtension\Model\System\Message;
5+
6+
use Magento\Framework\Module\Manager as ModuleManager;
7+
use Magento\Framework\Notification\MessageInterface;
8+
use Meta\BusinessExtension\Model\ResourceModel\MetaIssueNotification;
9+
10+
class ConflictingModulesNotification implements MessageInterface
11+
{
12+
13+
/**
14+
* @var MetaIssueNotification
15+
*/
16+
private MetaIssueNotification $metaIssueNotification;
17+
/**
18+
* @var ModuleManager
19+
*/
20+
private ModuleManager $moduleManager;
21+
22+
private static array $conflictingModules = ['Apptrian_MetaPixelApi'];
23+
private static string $meta_business_extension = 'Meta_BusinessExtension';
24+
private string $conflictingModulesFound = '';
25+
26+
public function __construct(
27+
MetaIssueNotification $metaIssueNotification,
28+
ModuleManager $moduleManager,
29+
) {
30+
$this->metaIssueNotification = $metaIssueNotification;
31+
$this->moduleManager = $moduleManager;
32+
}
33+
public function getIdentity()
34+
{
35+
$notification = $this->metaIssueNotification->loadVersionNotification();
36+
return $notification['notification_id'] ?? '';
37+
}
38+
39+
public function isDisplayed()
40+
{
41+
42+
//find out if the user enabled the Meta Business Extension
43+
$has_Meta_BusinessExtension = $this->moduleManager->isEnabled(self::$meta_business_extension);
44+
45+
//iterate through the user's module manager to see if they have any conflicting modules
46+
foreach(self::$conflictingModules as $conflictingModule) {
47+
if ($this->moduleManager->isEnabled($conflictingModule) && $has_Meta_BusinessExtension)
48+
{
49+
$this->conflictingModulesFound = $conflictingModule;
50+
return true;
51+
}
52+
}
53+
return false;
54+
}
55+
56+
57+
public function getText()
58+
{
59+
return sprintf( 'The following module conflicts with the Facebook & Instagram Extension: [%s] . Please disable the conflicting module.',
60+
$this->conflictingModulesFound);
61+
}
62+
63+
public function getSeverity()
64+
{
65+
return self::SEVERITY_CRITICAL;
66+
}
67+
68+
}

0 commit comments

Comments
 (0)