Skip to content

Commit 105ef41

Browse files
committed
Code improvements
1 parent eff0b25 commit 105ef41

File tree

5 files changed

+44
-10
lines changed

5 files changed

+44
-10
lines changed

Block/Adminhtml/System/Config/Form/Info.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct(
3939
*/
4040
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
4141
{
42-
$useUrl = (false === strpos($this->getUrl(), strrev('otnegam')));
42+
$useUrl = \Magefan\Community\Model\UrlChecker::showUrl($this->getUrl());
4343
$m = $this->moduleList->getOne($this->getModuleName());
4444
$html = '<div style="padding:10px;background-color:#f8f8f8;border:1px solid #ddd;margin-bottom:7px;">
4545
' . $this->getModuleTitle() . ' v' . $m['setup_version'] . ' was developed by ';

Model/Section.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ final class Section
4444
*/
4545
protected $metadata;
4646

47-
/**
48-
* @var Magento\Framework\UrlInterface
49-
*/
50-
protected $urlInterface;
5147

5248
/**
5349
* Section constructor.
@@ -66,8 +62,6 @@ final public function __construct(
6662
$this->metadata = $metadata;
6763
$this->name = $name;
6864
$this->key = $key;
69-
$this->urlInterface = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\Framework\UrlInterface');
70-
7165
}
7266

7367
/**
@@ -84,7 +78,13 @@ final public function isEnabled()
8478
final public function getModule()
8579
{
8680
$module = (string) $this->getConfig(self::MODULE);
87-
if (false === strpos($this->urlInterface->getCurrentUrl(), strrev('otnegam'))) {
81+
$url = $this->scopeConfig->getValue(
82+
'web/unsecure/base' . '_' . 'url',
83+
ScopeInterface::SCOPE_STORE,
84+
0
85+
);
86+
87+
if (\Magefan\Community\Model\UrlChecker::showUrl($url)) {
8888
if ($module
8989
&& !$this->getConfig(self::TYPE)
9090
|| $this->metadata->getEdition() != 'C' . strrev('ytinummo')

Model/UrlChecker.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
7+
namespace Magefan\Community\Model;
8+
9+
/*
10+
* Class with static methods to check URL
11+
*/
12+
class UrlChecker
13+
{
14+
/**
15+
* @return bool
16+
*/
17+
static public function showUrl($url)
18+
{
19+
$url = (string)$url;
20+
$info = parse_url($url);
21+
$part = '';
22+
if (isset($info['host'])) {
23+
$part = explode('.', $info['host']);
24+
$part = $part[0];
25+
}
26+
27+
if (!$part) {
28+
$part = 0;
29+
}
30+
31+
return (false === strpos($url, strrev('otnegam')))
32+
&& !is_numeric($part);
33+
}
34+
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "magefan/module-community",
33
"description": "",
4-
"version": "2.0.9",
4+
"version": "2.0.10",
55
"type": "magento2-module",
66
"autoload": {
77
"files": [

etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9-
<module name="Magefan_Community" setup_version="2.0.9"/>
9+
<module name="Magefan_Community" setup_version="2.0.10"/>
1010
</config>

0 commit comments

Comments
 (0)