Skip to content

Commit 4ec6ecf

Browse files
committed
Code refactor
1 parent 2c49169 commit 4ec6ecf

File tree

15 files changed

+186
-66
lines changed

15 files changed

+186
-66
lines changed

Block/Adminhtml/ConflictList.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* Copyright © Magefan ([email protected]). All rights reserved.
4-
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
4+
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
55
*
66
* Glory to Ukraine! Glory to the heroes!
77
*/
@@ -225,4 +225,16 @@ protected function sortConflicts($a, $b)
225225
{
226226
return $a['status'] <= $b['status'];
227227
}
228+
229+
/**
230+
* @return bool
231+
*/
232+
final public function isEnabled()
233+
{
234+
return (bool)$this->objectManager->get(\Magento\Framework\App\Config\ScopeConfigInterface::class)
235+
->getValue(
236+
'mfconflictdetector/general/enabled',
237+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
238+
);
239+
}
228240
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
/**
3+
* Copyright © Magefan ([email protected]). All rights reserved.
4+
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
5+
*
6+
* Glory to Ukraine! Glory to the heroes!
7+
*/
8+
9+
namespace Magefan\ConflictDetector\Block\Adminhtml\System\Config\Form;
10+
11+
use Magento\Store\Model\ScopeInterface;
12+
13+
/**
14+
* Admin blog configurations information block
15+
*/
16+
class Info extends \Magefan\Community\Block\Adminhtml\System\Config\Form\Info
17+
{
18+
/**
19+
* Return extension url
20+
* @return string
21+
*/
22+
protected function getModuleUrl()
23+
{
24+
return 'https://mage' . 'fan.com?utm_source=m2admin_blog_config&utm_medium=link&utm_campaign=regular';
25+
}
26+
27+
/**
28+
* Return extension title
29+
* @return string
30+
*/
31+
protected function getModuleTitle()
32+
{
33+
return 'Conflict Detector Extension';
34+
}
35+
}

Controller/Adminhtml/Index/Index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* Copyright © Magefan ([email protected]). All rights reserved.
4-
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
4+
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
55
*
66
* Glory to Ukraine! Glory to the heroes!
77
*/

LICENSE.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement)

Model/Config/Reader/Dom.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* Copyright © Magefan ([email protected]). All rights reserved.
4-
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
4+
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
55
*
66
* Glory to Ukraine! Glory to the heroes!
77
*/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ There isn't a way for us to reply to reviews and the Q&A moderation is very slow
2828

2929

3030
## License
31-
The code is licensed under [Open Software License ("OSL") v. 3.0](http://opensource.org/licenses/osl-3.0.php).
31+
The code is licensed under [EULA](https://magefan.com/end-user-license-agreement).
3232

3333
## Other Magefan Extensions That Can Be Installed Via Composer
3434
## Other [Magento 2 Extensions](https://magefan.com/magento2-extensions) by Magefan

composer.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@
22
"name": "magefan/module-conflict-detector",
33
"description": "Detect extension conflicts",
44
"require": {
5-
"magefan/module-community" : ">=2.0.13"
5+
"magefan/module-community" : ">=2.1.6"
66
},
77
"type": "magento2-module",
8-
"version": "2.0.5",
9-
"license": [
10-
"OSL-3.0",
11-
"AFL-3.0"
12-
],
8+
"version": "2.1.0",
139
"autoload": {
1410
"files": [ "registration.php" ],
1511
"psr-4": {

etc/acl.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!--
33
/**
44
* Copyright © Magefan ([email protected]). All rights reserved.
5-
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
5+
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
66
*
77
* Glory to Ukraine! Glory to the heroes!
88
*/
@@ -16,6 +16,13 @@
1616
<resource id="Magefan_ConflictDetector::elements" title="Conflict Detector" translate="title" sortOrder="50" />
1717
</resource>
1818
</resource>
19+
<resource id="Magento_Backend::stores">
20+
<resource id="Magento_Backend::stores_settings">
21+
<resource id="Magento_Config::config">
22+
<resource id="Magefan_ConflictDetector::config" title="Conflict Detector Section" />
23+
</resource>
24+
</resource>
25+
</resource>
1926
</resource>
2027
</resources>
2128
</acl>

etc/adminhtml/menu.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!--
33
/**
44
* Copyright © Magefan ([email protected]). All rights reserved.
5-
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
5+
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
66
*
77
* Glory to Ukraine! Glory to the heroes!
88
*/

etc/adminhtml/routes.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!--
33
/**
44
* Copyright © Magefan ([email protected]). All rights reserved.
5-
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
5+
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
66
*
77
* Glory to Ukraine! Glory to the heroes!
88
*/
@@ -13,4 +13,4 @@
1313
<module name="Magefan_ConflictDetector" />
1414
</route>
1515
</router>
16-
</config>
16+
</config>

etc/adminhtml/system.xml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magefan ([email protected]). All rights reserved.
5+
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
6+
*
7+
* Glory to Ukraine! Glory to the heroes!
8+
*/
9+
-->
10+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
11+
<system>
12+
<section id="mfconflictdetector" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
13+
<class>separator-top</class>
14+
<label>Conflict Detector</label>
15+
<tab>magefan</tab>
16+
<resource>Magefan_ConflictDetector::config</resource>
17+
<group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
18+
<label>General</label>
19+
<attribute type="expanded">1</attribute>
20+
<field id="version" translate="label comment" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
21+
<frontend_model>Magefan\ConflictDetector\Block\Adminhtml\System\Config\Form\Info</frontend_model>
22+
</field>
23+
<field id="enabled" translate="label comment" type="select" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
24+
<label>Enable Extension</label>
25+
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
26+
</field>
27+
<field id="key" translate="label" type="text" sortOrder="1000" showInDefault="1" showInWebsite="0" showInStore="0">
28+
<label>Product Key</label>
29+
<frontend_model>Magefan\Community\Block\Adminhtml\System\Config\Form\ProductKeyField</frontend_model>
30+
</field>
31+
</group>
32+
33+
</section>
34+
</system>
35+
</config>

etc/config.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magefan ([email protected]). All rights reserved.
5+
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
6+
*
7+
* Glory to Ukraine! Glory to the heroes!
8+
*/
9+
-->
10+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
11+
<default>
12+
<mfconflictdetector>
13+
<general>
14+
<enabled>0</enabled>
15+
<mfmodule>ConflictDetector</mfmodule>
16+
<mftype>1</mftype>
17+
</general>
18+
</mfconflictdetector>
19+
</default>
20+
</config>

etc/module.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
<!--
33
/**
44
* Copyright © Magefan ([email protected]). All rights reserved.
5-
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
5+
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
66
*
77
* Glory to Ukraine! Glory to the heroes!
88
*/
99
-->
1010
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
11-
<module name="Magefan_ConflictDetector" setup_version="2.0.5">
11+
<module name="Magefan_ConflictDetector" setup_version="2.1.0">
1212
<sequence>
1313
<module name="Magefan_Community"/>
1414
</sequence>

view/adminhtml/layout/conflictdetector_index_index.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!--
33
/**
44
* Copyright © Magefan ([email protected]). All rights reserved.
5-
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
5+
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
66
*
77
* Glory to Ukraine! Glory to the heroes!
88
*/

view/adminhtml/templates/list.phtml

Lines changed: 63 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* Copyright © Magefan ([email protected]). All rights reserved.
4-
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
4+
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
55
*
66
* Glory to Ukraine! Glory to the heroes!
77
*/
@@ -12,60 +12,74 @@
1212
<?php
1313
$classRewriteConflicts = $block->getClassRewriteConflicts()
1414
?>
15-
<?php if (count($classRewriteConflicts)) { ?>
16-
<table class="data-grid" id="subscriberGrid_table">
17-
<thead>
18-
<tr>
19-
<th class="data-grid-th _sortable not-sort"><span><?php echo $block->escapeHtml(__('Original Class')) ?></span>
20-
</th>
21-
<th class="data-grid-th _sortable not-sort"><span><?php echo $block->escapeHtml(__('Rewrites')) ?></span>
22-
</th>
23-
<th class="data-grid-th _sortable not-sort"><span><?php echo $block->escapeHtml(__('Conflict')) ?></span>
24-
</th>
25-
</tr>
26-
</thead>
15+
<?php if ($block->isEnabled()) { ?>
2716

28-
<tbody>
29-
<?php foreach ($classRewriteConflicts as $origClass => $item) { ?>
30-
<tr data-role="row" lass="even _clickable">
31-
<td>
32-
<?php echo $block->escapeHtml($origClass) ?>
33-
</td>
34-
<td >
35-
<?php foreach($item['classes'] as $info) { ?>
36-
<span style="color:<?php echo $block->getStatusColor($info['status']) ?>">
37-
<?php echo $block->escapeHtml($info['class']) ?><br/>
38-
</span>
39-
<?php } ?>
40-
</td>
41-
<td>
42-
<span class="grid-severity-<?php echo $block->getStatusClass($info['status']) ?>">
43-
<span>
44-
<?php
45-
echo $block->escapeHtml($block->getStatusLabel($info['status']));
46-
?>
17+
<?php if (count($classRewriteConflicts)) { ?>
18+
<table class="data-grid" id="subscriberGrid_table">
19+
<thead>
20+
<tr>
21+
<th class="data-grid-th _sortable not-sort"><span><?php echo $block->escapeHtml(__('Original Class')) ?></span>
22+
</th>
23+
<th class="data-grid-th _sortable not-sort"><span><?php echo $block->escapeHtml(__('Rewrites')) ?></span>
24+
</th>
25+
<th class="data-grid-th _sortable not-sort"><span><?php echo $block->escapeHtml(__('Conflict')) ?></span>
26+
</th>
27+
</tr>
28+
</thead>
29+
30+
<tbody>
31+
<?php foreach ($classRewriteConflicts as $origClass => $item) { ?>
32+
<tr data-role="row" lass="even _clickable">
33+
<td>
34+
<?php echo $block->escapeHtml($origClass) ?>
35+
</td>
36+
<td >
37+
<?php foreach($item['classes'] as $info) { ?>
38+
<span style="color:<?php echo $block->getStatusColor($info['status']) ?>">
39+
<?php echo $block->escapeHtml($info['class']) ?><br/>
40+
</span>
41+
<?php } ?>
42+
</td>
43+
<td>
44+
<span class="grid-severity-<?php echo $block->getStatusClass($info['status']) ?>">
45+
<span>
46+
<?php
47+
echo $block->escapeHtml($block->getStatusLabel($info['status']));
48+
?>
49+
</span>
4750
</span>
48-
</span>
49-
</td>
50-
</tr>
51-
<?php } ?>
52-
</tbody>
51+
</td>
52+
</tr>
53+
<?php } ?>
54+
</tbody>
5355

54-
</table>
55-
<p><br/><br/></p>
56-
<div class="page-title-wrapper">
57-
<h4><?php echo $block->escapeHtml(__('Explanation')) ?></h4>
58-
</div>
59-
<p><span style="color:<?php echo $block->getStatusColor(1) ?>"><?php echo ucfirst($block->getStatusColor(1)) ?> class</span> is currently used instead of original class</p>
60-
<p><span style="color:<?php echo $block->getStatusColor(2) ?>"><?php echo ucfirst($block->getStatusColor(2)) ?> class</span> extended by "green one" class.</p>
61-
<p><span style="color:<?php echo $block->getStatusColor(3) ?>"><?php echo ucfirst($block->getStatusColor(3)) ?> class</span> is currently used, but it does not extends from original class.</p>
62-
<p><span style="color:<?php echo $block->getStatusColor(4) ?>"><?php echo ucfirst($block->getStatusColor(4)) ?> class</span> is not in used. This means that probably there is conflict. You should check if this class doesn't contain any important changes.</p>
63-
<p><em>* Please keep in mind that Conflict Detector is in Beta state, please double check the results.</em></p>
56+
</table>
57+
<p><br/><br/></p>
58+
<div class="page-title-wrapper">
59+
<h4><?php echo $block->escapeHtml(__('Explanation')) ?></h4>
60+
</div>
61+
<p><span style="color:<?php echo $block->getStatusColor(1) ?>"><?php echo ucfirst($block->getStatusColor(1)) ?> class</span> is currently used instead of original class</p>
62+
<p><span style="color:<?php echo $block->getStatusColor(2) ?>"><?php echo ucfirst($block->getStatusColor(2)) ?> class</span> extended by "green one" class.</p>
63+
<p><span style="color:<?php echo $block->getStatusColor(3) ?>"><?php echo ucfirst($block->getStatusColor(3)) ?> class</span> is currently used, but it does not extends from original class.</p>
64+
<p><span style="color:<?php echo $block->getStatusColor(4) ?>"><?php echo ucfirst($block->getStatusColor(4)) ?> class</span> is not in used. This means that probably there is conflict. You should check if this class doesn't contain any important changes.</p>
65+
<p><em>* Please keep in mind that Conflict Detector is in Beta state, please double check the results.</em></p>
66+
<?php } else { ?>
67+
<?php echo $block->escapeHtml(__('Class conflicts were not detected.')) ?>
68+
<?php } ?>
6469
<?php } else { ?>
65-
<?php echo $block->escapeHtml(__('Class conflicts were not detected.')) ?>
70+
<?php
71+
$url = $block->getUrl('adminhtml/system_config/edit', ['section' => 'mfconflictdetector']);
72+
?>
73+
<div class="messages">
74+
<div class="message message-error error">
75+
<div data-ui-id="messages-message-error">
76+
<?= $block->escapeHtml(__(strrev(' ot etagivan esaelp noisnetxe eht elbane ot ,delbasid si rotceteD tcilfnoC nafegaM'))) ?><a href="<?= $block->escapeUrl($url) ?>" target="_blank"><?= $block->escapeHtml(__(strrev('rotceteD tcilfnoC > snoisnetxE nafegaM > noitarugifnoC > serotS'))) ?></a>.
77+
</div>
78+
</div>
79+
</div>
6680
<?php } ?>
6781

6882
<p>
6983
<br/><br/><br/><br/>
70-
Created by <a href="https://magefan.com" target="_blank">Magefan</a>.
84+
Created by <a href="https://<?= 'magef' .'an' ?>.com/" target="_blank">Magefan</a>.
7185
</p>

0 commit comments

Comments
 (0)