Skip to content

Commit

Permalink
Added plugin version into admin configuration (#28)
Browse files Browse the repository at this point in the history
* Added plugin version into admin configuration
  • Loading branch information
andrii-onufriichuk authored May 15, 2023
1 parent eff42d5 commit 5007de4
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
43 changes: 43 additions & 0 deletions Block/Adminhtml/System/Config/Form/Field/Version.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

declare(strict_types=1);

namespace Rvvup\Payments\Block\Adminhtml\System\Config\Form\Field;

use Magento\Backend\Block\Template\Context;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Rvvup\Payments\Model\Environment\GetEnvironmentVersions;

class Version extends Field
{
/**
* @var GetEnvironmentVersions
*/
private GetEnvironmentVersions $environmentVersions;

/**
* @param Context $context
* @param GetEnvironmentVersions $environmentVersions
* @param array $data
*/
public function __construct(
Context $context,
GetEnvironmentVersions $environmentVersions,
array $data = []
) {
$this->environmentVersions = $environmentVersions;
parent::__construct(
$context,
$data
);
}

protected function _getElementHtml(AbstractElement $element)
{
$element->setDisabled('disabled');
$element->setValue($this->environmentVersions->getRvvupModuleVersion());

return $element->getElementHtml();
}
}
2 changes: 1 addition & 1 deletion Model/Environment/GetEnvironmentVersions.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private function getCachedEnvironmentVersions(): ?string
*
* @return string
*/
private function getRvvupModuleVersion(): string
public function getRvvupModuleVersion(): string
{
// Attempt to figure out what plugin version we have depending on installation method
$packages = $this->composerInformation->getInstalledMagentoPackages();
Expand Down
4 changes: 4 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
<field id="key_validation" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
<frontend_model>Rvvup\Payments\Block\Adminhtml\CredentialValidator</frontend_model>
</field>
<field id="plugin_version" type="text" sortOrder="35" showInWebsite="1" showInStore="1" showInDefault="1" translate="label">
<label>Plugin version</label>
<frontend_model>Rvvup\Payments\Block\Adminhtml\System\Config\Form\Field\Version</frontend_model>
</field>
<field id="environment" type="text" sortOrder="40" showInWebsite="1" showInStore="1" showInDefault="1" translate="label">
<label>Current Environment</label>
<backend_model>Rvvup\Payments\Model\Config\Env\Indicator</backend_model>
Expand Down

0 comments on commit 5007de4

Please sign in to comment.