Skip to content

Commit

Permalink
Set v1.0.7. Added php74 to composer. Added current module version to …
Browse files Browse the repository at this point in the history
…Configs in Admin. Added installed_module_version
  • Loading branch information
Returnless committed Mar 2, 2021
1 parent cfff596 commit 7a55eea
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Controller/Order/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ protected function returnResponse($result = null)
{
header("Content-Type: application/json; charset=utf-8");

if (isset($result['installed_module_version']) && !empty($result['installed_module_version'])) {
$this->response['installed_module_version'] = $result['installed_module_version'];
}

if (isset($result['result']) && !empty($result['result'])) {
$this->response['result'] = $result['result'];
}
Expand Down
17 changes: 16 additions & 1 deletion Model/Api/OrderInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Returnless\Connector\Model\Api;

use Magento\Framework\Module\ResourceInterface;
use Returnless\Connector\Api\OrderInfoInterface;
use Magento\Sales\Model\OrderRepository;
use Magento\Catalog\Model\ProductRepository;
Expand All @@ -23,6 +24,16 @@ class OrderInfo implements OrderInfoInterface
*/
const PRODUCT_TYPE_BUNDLE = 'bundle';

/**
* const NAMESPACE_MODULE
*/
const NAMESPACE_MODULE = 'Returnless_Connector';

/**
* @var ResourceInterface
*/
protected $moduleResource;

/**
* @var bool
*/
Expand Down Expand Up @@ -68,21 +79,24 @@ class OrderInfo implements OrderInfoInterface
* @param LoggerInterface $logger
* @param Image $image
* @param Config $config
* @param ResourceInterface $moduleResource
*/
public function __construct(
OrderRepository $orderRepository,
ProductRepository $productRepository,
SearchCriteriaBuilder $searchCriteriaBuilder,
LoggerInterface $logger,
Image $image,
Config $config
Config $config,
ResourceInterface $moduleResource
) {
$this->orderRepository = $orderRepository;
$this->productRepository = $productRepository;
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
$this->logger = $logger;
$this->image = $image;
$this->config = $config;
$this->moduleResource = $moduleResource;
}

/**
Expand All @@ -92,6 +106,7 @@ public function getOrderInfoReturnless($incrementId)
{
$response['return_code'] = 112;
$response['return_message'] = '';
$response['installed_module_version'] = $this->moduleResource->getDbVersion(self::NAMESPACE_MODULE);
$orderInfo = [];

$this->logger->debug('[RET_ORDER_INFO] Increment Id', [$incrementId]);
Expand Down
75 changes: 75 additions & 0 deletions Model/Config/ModuleVersion.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

namespace Returnless\Connector\Model\Config;

use Magento\Framework\App\Config\Value;
use Magento\Framework\Model\Context;
use Magento\Framework\Registry;
use Magento\Framework\App\Cache\TypeListInterface;
use Magento\Framework\Model\ResourceModel\AbstractResource;
use Magento\Framework\Data\Collection\AbstractDb;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Module\ResourceInterface;

/**
* Class ModuleVersion
* @package Returnless\Connector\Model\Config
*/
class ModuleVersion extends Value
{
/**
* const NAMESPACE_MODULE
*/
const NAMESPACE_MODULE = 'Returnless_Connector';

/**
* @var ResourceInterface
*/
private $moduleResource;

/**
* ModuleVersion constructor.
*
* @param Context $context
* @param Registry $registry
* @param ScopeConfigInterface $config
* @param TypeListInterface $cacheTypeList
* @param ResourceInterface $moduleResource
* @param AbstractResource|null $resource
* @param AbstractDb|null $resourceCollection
* @param array $data
*/
public function __construct(
Context $context,
Registry $registry,
ScopeConfigInterface $config,
TypeListInterface $cacheTypeList,
ResourceInterface $moduleResource,
AbstractResource $resource = null,
AbstractDb $resourceCollection = null,
array $data = []
) {
$this->moduleResource = $moduleResource;
parent::__construct(
$context,
$registry,
$config,
$cacheTypeList,
$resource,
$resourceCollection,
$data
);
}

/**
* Inject current installed module version as the config value.
*
* @return void
*/
public function afterLoad()
{
$moduleVersion = $this->moduleResource->getDbVersion(self::NAMESPACE_MODULE);

$this->setValue($moduleVersion);
}
}
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Returnless Connector",
"type": "magento2-module",
"require": {
"php": "~7.0.0|7.0.2|7.0.4|~7.0.6|~7.1.0|~7.2.0|~7.3.0"
"php": "~7.0.0|7.0.2|7.0.4|~7.0.6|~7.1.0|~7.2.0|~7.3.0|~7.4.0"
},
"autoload": {
"files": [
Expand All @@ -17,5 +17,5 @@
"OSL-3.0",
"AFL-3.0"
],
"version": "1.0.6"
"version": "1.0.7"
}
4 changes: 4 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
<resource>Returnless_Connector::returnless_connector_config</resource>
<group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>General Config</label>
<field id="module_version" translate="label" type="label" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Current Version Installed</label>
<backend_model>Returnless\Connector\Model\Config\ModuleVersion</backend_model>
</field>
<field id="enabled" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Returnless_Connector" setup_version="1.0.6">
<module name="Returnless_Connector" setup_version="1.0.7">
<sequence>
<module name="Magento_Sales"/>
</sequence>
Expand Down

0 comments on commit 7a55eea

Please sign in to comment.