Skip to content

Commit

Permalink
Code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ihorvansach committed Nov 29, 2021
1 parent 2c49169 commit 4ec6ecf
Show file tree
Hide file tree
Showing 15 changed files with 186 additions and 66 deletions.
14 changes: 13 additions & 1 deletion Block/Adminhtml/ConflictList.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © Magefan (support@magefan.com). All rights reserved.
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
*
* Glory to Ukraine! Glory to the heroes!
*/
Expand Down Expand Up @@ -225,4 +225,16 @@ protected function sortConflicts($a, $b)
{
return $a['status'] <= $b['status'];
}

/**
* @return bool
*/
final public function isEnabled()
{
return (bool)$this->objectManager->get(\Magento\Framework\App\Config\ScopeConfigInterface::class)
->getValue(
'mfconflictdetector/general/enabled',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
);
}
}
35 changes: 35 additions & 0 deletions Block/Adminhtml/System/Config/Form/Info.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* Copyright © Magefan (support@magefan.com). All rights reserved.
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
*
* Glory to Ukraine! Glory to the heroes!
*/

namespace Magefan\ConflictDetector\Block\Adminhtml\System\Config\Form;

use Magento\Store\Model\ScopeInterface;

/**
* Admin blog configurations information block
*/
class Info extends \Magefan\Community\Block\Adminhtml\System\Config\Form\Info
{
/**
* Return extension url
* @return string
*/
protected function getModuleUrl()
{
return 'https://mage' . 'fan.com?utm_source=m2admin_blog_config&utm_medium=link&utm_campaign=regular';
}

/**
* Return extension title
* @return string
*/
protected function getModuleTitle()
{
return 'Conflict Detector Extension';
}
}
2 changes: 1 addition & 1 deletion Controller/Adminhtml/Index/Index.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © Magefan (support@magefan.com). All rights reserved.
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
*
* Glory to Ukraine! Glory to the heroes!
*/
Expand Down
1 change: 1 addition & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement)
2 changes: 1 addition & 1 deletion Model/Config/Reader/Dom.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © Magefan (support@magefan.com). All rights reserved.
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
*
* Glory to Ukraine! Glory to the heroes!
*/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ There isn't a way for us to reply to reviews and the Q&A moderation is very slow


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

## Other Magefan Extensions That Can Be Installed Via Composer
## Other [Magento 2 Extensions](https://magefan.com/magento2-extensions) by Magefan
Expand Down
8 changes: 2 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@
"name": "magefan/module-conflict-detector",
"description": "Detect extension conflicts",
"require": {
"magefan/module-community" : ">=2.0.13"
"magefan/module-community" : ">=2.1.6"
},
"type": "magento2-module",
"version": "2.0.5",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"version": "2.1.0",
"autoload": {
"files": [ "registration.php" ],
"psr-4": {
Expand Down
9 changes: 8 additions & 1 deletion etc/acl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
/**
* Copyright © Magefan (support@magefan.com). All rights reserved.
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
*
* Glory to Ukraine! Glory to the heroes!
*/
Expand All @@ -16,6 +16,13 @@
<resource id="Magefan_ConflictDetector::elements" title="Conflict Detector" translate="title" sortOrder="50" />
</resource>
</resource>
<resource id="Magento_Backend::stores">
<resource id="Magento_Backend::stores_settings">
<resource id="Magento_Config::config">
<resource id="Magefan_ConflictDetector::config" title="Conflict Detector Section" />
</resource>
</resource>
</resource>
</resource>
</resources>
</acl>
Expand Down
2 changes: 1 addition & 1 deletion etc/adminhtml/menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
/**
* Copyright © Magefan (support@magefan.com). All rights reserved.
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
*
* Glory to Ukraine! Glory to the heroes!
*/
Expand Down
4 changes: 2 additions & 2 deletions etc/adminhtml/routes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
/**
* Copyright © Magefan (support@magefan.com). All rights reserved.
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
*
* Glory to Ukraine! Glory to the heroes!
*/
Expand All @@ -13,4 +13,4 @@
<module name="Magefan_ConflictDetector" />
</route>
</router>
</config>
</config>
35 changes: 35 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magefan (support@magefan.com). All rights reserved.
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
*
* Glory to Ukraine! Glory to the heroes!
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<section id="mfconflictdetector" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
<class>separator-top</class>
<label>Conflict Detector</label>
<tab>magefan</tab>
<resource>Magefan_ConflictDetector::config</resource>
<group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
<label>General</label>
<attribute type="expanded">1</attribute>
<field id="version" translate="label comment" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
<frontend_model>Magefan\ConflictDetector\Block\Adminhtml\System\Config\Form\Info</frontend_model>
</field>
<field id="enabled" translate="label comment" type="select" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Enable Extension</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="key" translate="label" type="text" sortOrder="1000" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Product Key</label>
<frontend_model>Magefan\Community\Block\Adminhtml\System\Config\Form\ProductKeyField</frontend_model>
</field>
</group>

</section>
</system>
</config>
20 changes: 20 additions & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magefan (support@magefan.com). All rights reserved.
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
*
* Glory to Ukraine! Glory to the heroes!
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<mfconflictdetector>
<general>
<enabled>0</enabled>
<mfmodule>ConflictDetector</mfmodule>
<mftype>1</mftype>
</general>
</mfconflictdetector>
</default>
</config>
4 changes: 2 additions & 2 deletions etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<!--
/**
* Copyright © Magefan (support@magefan.com). All rights reserved.
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
*
* Glory to Ukraine! Glory to the heroes!
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magefan_ConflictDetector" setup_version="2.0.5">
<module name="Magefan_ConflictDetector" setup_version="2.1.0">
<sequence>
<module name="Magefan_Community"/>
</sequence>
Expand Down
2 changes: 1 addition & 1 deletion view/adminhtml/layout/conflictdetector_index_index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
/**
* Copyright © Magefan (support@magefan.com). All rights reserved.
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
*
* Glory to Ukraine! Glory to the heroes!
*/
Expand Down
112 changes: 63 additions & 49 deletions view/adminhtml/templates/list.phtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © Magefan (support@magefan.com). All rights reserved.
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
*
* Glory to Ukraine! Glory to the heroes!
*/
Expand All @@ -12,60 +12,74 @@
<?php
$classRewriteConflicts = $block->getClassRewriteConflicts()
?>
<?php if (count($classRewriteConflicts)) { ?>
<table class="data-grid" id="subscriberGrid_table">
<thead>
<tr>
<th class="data-grid-th _sortable not-sort"><span><?php echo $block->escapeHtml(__('Original Class')) ?></span>
</th>
<th class="data-grid-th _sortable not-sort"><span><?php echo $block->escapeHtml(__('Rewrites')) ?></span>
</th>
<th class="data-grid-th _sortable not-sort"><span><?php echo $block->escapeHtml(__('Conflict')) ?></span>
</th>
</tr>
</thead>
<?php if ($block->isEnabled()) { ?>

<tbody>
<?php foreach ($classRewriteConflicts as $origClass => $item) { ?>
<tr data-role="row" lass="even _clickable">
<td>
<?php echo $block->escapeHtml($origClass) ?>
</td>
<td >
<?php foreach($item['classes'] as $info) { ?>
<span style="color:<?php echo $block->getStatusColor($info['status']) ?>">
<?php echo $block->escapeHtml($info['class']) ?><br/>
</span>
<?php } ?>
</td>
<td>
<span class="grid-severity-<?php echo $block->getStatusClass($info['status']) ?>">
<span>
<?php
echo $block->escapeHtml($block->getStatusLabel($info['status']));
?>
<?php if (count($classRewriteConflicts)) { ?>
<table class="data-grid" id="subscriberGrid_table">
<thead>
<tr>
<th class="data-grid-th _sortable not-sort"><span><?php echo $block->escapeHtml(__('Original Class')) ?></span>
</th>
<th class="data-grid-th _sortable not-sort"><span><?php echo $block->escapeHtml(__('Rewrites')) ?></span>
</th>
<th class="data-grid-th _sortable not-sort"><span><?php echo $block->escapeHtml(__('Conflict')) ?></span>
</th>
</tr>
</thead>

<tbody>
<?php foreach ($classRewriteConflicts as $origClass => $item) { ?>
<tr data-role="row" lass="even _clickable">
<td>
<?php echo $block->escapeHtml($origClass) ?>
</td>
<td >
<?php foreach($item['classes'] as $info) { ?>
<span style="color:<?php echo $block->getStatusColor($info['status']) ?>">
<?php echo $block->escapeHtml($info['class']) ?><br/>
</span>
<?php } ?>
</td>
<td>
<span class="grid-severity-<?php echo $block->getStatusClass($info['status']) ?>">
<span>
<?php
echo $block->escapeHtml($block->getStatusLabel($info['status']));
?>
</span>
</span>
</span>
</td>
</tr>
<?php } ?>
</tbody>
</td>
</tr>
<?php } ?>
</tbody>

</table>
<p><br/><br/></p>
<div class="page-title-wrapper">
<h4><?php echo $block->escapeHtml(__('Explanation')) ?></h4>
</div>
<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>
<p><span style="color:<?php echo $block->getStatusColor(2) ?>"><?php echo ucfirst($block->getStatusColor(2)) ?> class</span> extended by "green one" class.</p>
<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>
<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>
<p><em>* Please keep in mind that Conflict Detector is in Beta state, please double check the results.</em></p>
</table>
<p><br/><br/></p>
<div class="page-title-wrapper">
<h4><?php echo $block->escapeHtml(__('Explanation')) ?></h4>
</div>
<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>
<p><span style="color:<?php echo $block->getStatusColor(2) ?>"><?php echo ucfirst($block->getStatusColor(2)) ?> class</span> extended by "green one" class.</p>
<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>
<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>
<p><em>* Please keep in mind that Conflict Detector is in Beta state, please double check the results.</em></p>
<?php } else { ?>
<?php echo $block->escapeHtml(__('Class conflicts were not detected.')) ?>
<?php } ?>
<?php } else { ?>
<?php echo $block->escapeHtml(__('Class conflicts were not detected.')) ?>
<?php
$url = $block->getUrl('adminhtml/system_config/edit', ['section' => 'mfconflictdetector']);
?>
<div class="messages">
<div class="message message-error error">
<div data-ui-id="messages-message-error">
<?= $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>.
</div>
</div>
</div>
<?php } ?>

<p>
<br/><br/><br/><br/>
Created by <a href="https://magefan.com" target="_blank">Magefan</a>.
Created by <a href="https://<?= 'magef' .'an' ?>.com/" target="_blank">Magefan</a>.
</p>

0 comments on commit 4ec6ecf

Please sign in to comment.