|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © Magefan ([email protected]). All rights reserved. |
| 4 | + * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). |
| 5 | + */ |
| 6 | + |
| 7 | +namespace Magefan\Community\Block\Adminhtml\System\Config\Form; |
| 8 | + |
| 9 | +use Magento\Store\Model\ScopeInterface; |
| 10 | + |
| 11 | +/** |
| 12 | + * Admin Magefan configurations information block |
| 13 | + */ |
| 14 | +class Info extends \Magento\Config\Block\System\Config\Form\Field |
| 15 | +{ |
| 16 | + /** |
| 17 | + * @var \Magento\Framework\Module\ModuleListInterface |
| 18 | + */ |
| 19 | + protected $moduleList; |
| 20 | + |
| 21 | + /** |
| 22 | + * @param \Magento\Framework\Module\ModuleListInterface $moduleList |
| 23 | + * @param \Magento\Backend\Block\Template\Context $context |
| 24 | + * @param array $data |
| 25 | + */ |
| 26 | + public function __construct( |
| 27 | + \Magento\Framework\Module\ModuleListInterface $moduleList, |
| 28 | + \Magento\Backend\Block\Template\Context $context, |
| 29 | + array $data = [] |
| 30 | + ) { |
| 31 | + parent::__construct($context, $data); |
| 32 | + $this->moduleList = $moduleList; |
| 33 | + } |
| 34 | + |
| 35 | + /** |
| 36 | + * Return info block html |
| 37 | + * @param \Magento\Framework\Data\Form\Element\AbstractElement $element |
| 38 | + * @return string |
| 39 | + */ |
| 40 | + public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) |
| 41 | + { |
| 42 | + $m = $this->moduleList->getOne($this->getModuleName()); |
| 43 | + $html = '<div style="padding:10px;background-color:#f8f8f8;border:1px solid #ddd;margin-bottom:7px;"> |
| 44 | + ' . $this->getModuleTitle() . ' v' . $m['setup_version'] . ' was developed by <a href="' . $this->getModuleUrl() . '" target="_blank">Magefan</a>. |
| 45 | + </div>'; |
| 46 | + |
| 47 | + return $html; |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * Return extension url |
| 52 | + * @return string |
| 53 | + */ |
| 54 | + protected function getModuleUrl() |
| 55 | + { |
| 56 | + return 'https://magefan.com/'; |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * Return extension title |
| 61 | + * @return string |
| 62 | + */ |
| 63 | + protected function getModuleTitle() |
| 64 | + { |
| 65 | + return ucwords(str_replace('_', ' ', $this->getModuleName())) . ' Extension'; |
| 66 | + } |
| 67 | +} |
0 commit comments