Skip to content

Commit 2e0cd00

Browse files
authored
Merge pull request #6 from magefan/2869-Magefan-Community-Licence-Change
2869 magefan community licence change
2 parents 6a22b02 + 568792a commit 2e0cd00

File tree

3 files changed

+57
-6
lines changed

3 files changed

+57
-6
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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\Block\Adminhtml\System\Config\Form;
8+
9+
use Magento\Config\Block\System\Config\Form\Field;
10+
use Magento\Backend\Block\Template\Context;
11+
use Magefan\Community\Model\Section;
12+
use Magento\Framework\App\ObjectManager;
13+
14+
/**
15+
* Class Product Key Field
16+
*/
17+
class ProductKeyField extends Field
18+
{
19+
/**
20+
* Retrieve HTML markup for given form element
21+
*
22+
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
23+
* @return string
24+
*/
25+
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
26+
{
27+
$fieldConfig = $element->getFieldConfig();
28+
$path = explode('/', $fieldConfig['path']);
29+
$path = $path[0];
30+
31+
$section = ObjectManager::getInstance()->create(Section::class, ['name' => $path]);
32+
if ($section->getModule()) {
33+
if (!$element->getComment()) {
34+
$url = strrev('/stcudorp/remotsuc/elbadaolnwod/moc.nafegam//:sptth');
35+
$element->setComment('You can find product key in your <a href="' . $url . '" target="_blank">Magefan account</a>.');
36+
}
37+
return parent::render($element);
38+
} else {
39+
return '';
40+
}
41+
}
42+
}

Model/Section.php

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

47+
/**
48+
* @var Magento\Framework\UrlInterface
49+
*/
50+
protected $urlInterface;
51+
4752
/**
4853
* Section constructor.
4954
* @param ScopeConfigInterface $scopeConfig
@@ -61,6 +66,8 @@ final public function __construct(
6166
$this->metadata = $metadata;
6267
$this->name = $name;
6368
$this->key = $key;
69+
$this->urlInterface = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\Framework\UrlInterface');
70+
6471
}
6572

6673
/**
@@ -77,11 +84,13 @@ final public function isEnabled()
7784
final public function getModule()
7885
{
7986
$module = (string) $this->getConfig(self::MODULE);
80-
if ($module
81-
&& !$this->getConfig(self::TYPE)
82-
|| $this->metadata->getEdition() != 'C' . strrev('ytinummo')
83-
) {
84-
return $module;
87+
if (false === strpos($this->urlInterface->getCurrentUrl(), strrev('etisotnegam'))) {
88+
if ($module
89+
&& !$this->getConfig(self::TYPE)
90+
|| $this->metadata->getEdition() != 'C' . strrev('ytinummo')
91+
) {
92+
return $module;
93+
}
8594
}
8695
return false;
8796
}

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.6",
4+
"version": "2.0.7",
55
"type": "magento2-module",
66
"autoload": {
77
"files": [

0 commit comments

Comments
 (0)