Skip to content

Commit 43183e1

Browse files
committed
Add initial files
0 parents  commit 43183e1

File tree

5 files changed

+91
-0
lines changed

5 files changed

+91
-0
lines changed

Plugin/DisableWithAjax.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Yireo\MspDevToolsFixes\Plugin;
4+
5+
use Magento\Framework\App\Request\Http;
6+
use MSP\DevTools\Model\Config;
7+
8+
class DisableWithAjax
9+
{
10+
/**
11+
* @var Http
12+
*/
13+
private $http;
14+
15+
/**
16+
* DisableWithAjax constructor.
17+
* @param Http $http
18+
*/
19+
public function __construct(Http $http)
20+
{
21+
$this->http = $http;
22+
}
23+
24+
/**
25+
* @param Config $config
26+
* @param bool $return
27+
* @return bool
28+
*/
29+
public function afterCanInjectCode(Config $config, bool $return)
30+
{
31+
if ($return === true && $this->isAjax()) {
32+
return false;
33+
}
34+
35+
return $return;
36+
}
37+
38+
/**
39+
* @return bool
40+
*/
41+
private function isAjax(): bool
42+
{
43+
$contentType = $this->http->getHeader('Content-Type');
44+
if ($contentType === 'application/json') {
45+
return true;
46+
}
47+
48+
return false;
49+
}
50+
}

composer.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "yireo/msp-dev-tools-fixes",
3+
"version": "1.0.0",
4+
"description": "N/A",
5+
"type": "magento2-module",
6+
"require": {
7+
"magento/framework": "*"
8+
},
9+
"license": [
10+
"Proprietary"
11+
],
12+
"autoload": {
13+
"files": [
14+
"registration.php"
15+
],
16+
"psr-4": {
17+
"Yireo\\MspDevToolsFixes\\": ""
18+
}
19+
}
20+
}

etc/di.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0"?>
2+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
4+
<type name="MSP\DevTools\Model\Config">
5+
<plugin name="Yireo_MspDevToolsFixes::disableWithAjax" type="Yireo\MspDevToolsFixes\Plugin\DisableWithAjax"/>
6+
</type>
7+
</config>

etc/module.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0"?>
2+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
4+
<module name="Yireo_MspDevToolsFixes">
5+
<sequence>
6+
<module name="MSP_DevTools"/>
7+
</sequence>
8+
</module>
9+
</config>

registration.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
use Magento\Framework\Component\ComponentRegistrar;
4+
5+
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Yireo_MspDevToolsFixes', __DIR__);

0 commit comments

Comments
 (0)