Skip to content

Commit ea749b5

Browse files
release v2.3.0 (#30)
* PLUG-131: PHPStan (#26) * PLUG-152: Add release channel config option (#29) * PLUG-151: Settings visibility --------- Co-authored-by: artyom-jaksov-tl <[email protected]>
1 parent 5bc230d commit ea749b5

26 files changed

+198
-85
lines changed

.github/workflows/phpstan.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ jobs:
1919
- name: Create branch for Composer and remove version from composer.json
2020
run: git checkout -b continuous-integration-test-branch && sed -i '/version/d' ./composer.json
2121

22+
- name: Remove PHPStan duplicate include
23+
run: sed -i '/vendor\/bitexpert/d' ./phpstan.neon
24+
2225
- name: Upload our code into the docker container
2326
run: docker cp $(pwd) magento-project-community-edition:/data/extensions/
2427

Api/Config/System/SettingInterface.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ interface SettingInterface
2020
public const XML_PATH_SEND_ORDER_EMAIL = 'payment/truelayer/send_order_email';
2121
public const XML_PATH_SEND_INVOICE_EMAIL = 'payment/truelayer/send_invoice_email';
2222
public const XML_PATH_BANKING_PROVIDERS = 'payment/truelayer/banking_providers';
23+
public const XML_PATH_RELEASE_CHANNEL = 'payment/truelayer/release_channel';
2324
public const XML_PATH_PAYMENT_PAGE_PRIMARY_COLOR = 'payment/truelayer/payment_page_primary_color';
2425
public const XML_PATH_PAYMENT_PAGE_SECONDARY_COLOR = 'payment/truelayer/payment_page_secondary_color';
2526
public const XML_PATH_PAYMENT_PAGE_TERTIARY_COLOR = 'payment/truelayer/payment_page_tertiary_color';
@@ -48,6 +49,15 @@ public function getMaximumOrderTotal(): float;
4849
*/
4950
public function getBankingProviders(?int $storeId = null): array;
5051

52+
/**
53+
* Get associated array of credentials
54+
*
55+
* @param int|null $storeId
56+
*
57+
* @return string
58+
*/
59+
public function getReleaseChannel(?int $storeId = null): string;
60+
5161
/**
5262
* Get payment page primary color
5363
*

Api/Log/LogServiceInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ interface LogServiceInterface
1919
* @param string $type
2020
* @param mixed $data
2121
*/
22-
public function error(string $type, $data): LogServiceInterface;
22+
public function error(string $type, $data = ''): LogServiceInterface;
2323

2424
/**
2525
* Add record to debug log
2626
*
2727
* @param string $type
2828
* @param mixed $data
2929
*/
30-
public function debug(string $type, $data): LogServiceInterface;
30+
public function debug(string $type, $data = ''): LogServiceInterface;
3131

3232
/**
3333
* @param string|int $prefix

Block/Adminhtml/System/Config/Button/Credentials.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ public function getApiCheckUrl(): string
9292
public function getButtonHtml(): string
9393
{
9494
try {
95-
return $this->getLayout()
96-
->createBlock(Button::class)
97-
->setData(['id' => 'truelayer-button_credentials', 'label' => __('Check Credentials')])
98-
->toHtml();
95+
/** @var \Magento\Framework\View\Element\AbstractBlock $block */
96+
$block = $this->getLayout()->createBlock(Button::class);
97+
$block->setData(['id' => 'truelayer-button_credentials', 'label' => __('Check Credentials')]);
98+
return $block->toHtml();
9999
} catch (Exception $e) {
100100
$this->logger->error('Credentials check', $e->getMessage());
101101
return '';

Block/Adminhtml/System/Config/Button/DebugCheck.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,13 @@ public function getDebugCheckUrl(): string
5858
public function getButtonHtml(): string
5959
{
6060
try {
61-
return $this->getLayout()
62-
->createBlock(Button::class)
63-
->setData([
64-
'id' => 'truelayer-button_debug',
65-
'label' => __('Check last 100 debug log records')
66-
])->toHtml();
61+
/** @var \Magento\Framework\View\Element\AbstractBlock $block */
62+
$block = $this->getLayout()->createBlock(Button::class);
63+
$block->setData([
64+
'id' => 'truelayer-button_debug',
65+
'label' => __('Check last 100 debug log records')
66+
]);
67+
return $block->toHtml();
6768
} catch (Exception $e) {
6869
return '';
6970
}

Block/Adminhtml/System/Config/Button/ErrorCheck.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,13 @@ public function getErrorCheckUrl(): string
5858
public function getButtonHtml(): string
5959
{
6060
try {
61-
return $this->getLayout()
62-
->createBlock(Button::class)
63-
->setData([
64-
'id' => 'truelayer-button_error',
65-
'label' => __('Check last 100 error log records')
66-
])->toHtml();
61+
/** @var \Magento\Framework\View\Element\AbstractBlock $block */
62+
$block = $this->getLayout()->createBlock(Button::class);
63+
$block->setData([
64+
'id' => 'truelayer-button_error',
65+
'label' => __('Check last 100 error log records')
66+
]);
67+
return $block->toHtml();
6768
} catch (Exception $e) {
6869
return '';
6970
}

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
66
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [v2.3.0] - 2024-09-20
9+
10+
### Added
11+
12+
- Release channel configuration option
13+
- Fix settings visibility based on scopes
14+
15+
### Changed
16+
17+
- Stricter PHPStan rules
18+
819
## [v2.2.0] - 2024-09-02
920

1021
### Added

Gateway/Command/AbstractCommand.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ protected function getOrder(array $subject): OrderInterface
6565

6666
/**
6767
* @param array $subject
68-
* @return mixed
6968
*/
7069
abstract protected function executeCommand(array $subject): void;
7170
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* Copyright © TrueLayer Ltd. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace TrueLayer\Connect\Model\Config\Source;
9+
10+
use Magento\Framework\Data\OptionSourceInterface;
11+
12+
/**
13+
* ReleaseChannel Options Source model
14+
*/
15+
class ReleaseChannel implements OptionSourceInterface
16+
{
17+
public const GENERAL_AVAILABILITY = 'general_availability';
18+
public const PUBLIC_BETA = 'public_beta';
19+
public const PRIVATE_BETA = 'private_beta';
20+
21+
/**
22+
* Returns mode option source array
23+
*
24+
* @return array
25+
*/
26+
public function toOptionArray(): array
27+
{
28+
return [
29+
['value' => self::GENERAL_AVAILABILITY, 'label' => __('General Availability')],
30+
['value' => self::PUBLIC_BETA, 'label' => __('Public Beta')],
31+
['value' => self::PRIVATE_BETA, 'label' => __('Private Beta')]
32+
];
33+
}
34+
}

Model/Config/System/SettingsRepository.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace TrueLayer\Connect\Model\Config\System;
99

1010
use TrueLayer\Connect\Api\Config\System\SettingInterface;
11+
use TrueLayer\Connect\Model\Config\Source\ReleaseChannel;
1112

1213
/**
1314
* Debug provider class
@@ -43,6 +44,14 @@ public function getBankingProviders(?int $storeId = null): array
4344
}
4445
}
4546

47+
/**
48+
* @inheritDoc
49+
*/
50+
public function getReleaseChannel(?int $storeId = null): string
51+
{
52+
return $this->getStoreValue(self::XML_PATH_RELEASE_CHANNEL, $storeId) ?: ReleaseChannel::GENERAL_AVAILABILITY;
53+
}
54+
4655
/**
4756
* @inheritDoc
4857
*/

Model/Transaction/Payment/PaymentTransactionRepository.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public function create(): PaymentTransactionDataInterface
5454

5555
/**
5656
* @inheritDoc
57+
* @return PaymentTransactionDataModel
5758
*/
5859
public function get(int $entityId): PaymentTransactionDataInterface
5960
{
@@ -64,12 +65,16 @@ public function get(int $entityId): PaymentTransactionDataInterface
6465
$exceptionMsg = self::NO_SUCH_ENTITY_EXCEPTION;
6566
throw new NoSuchEntityException(__($exceptionMsg, $entityId));
6667
}
67-
return $this->dataFactory->create()
68-
->load($entityId);
68+
69+
/** @var PaymentTransactionDataModel $transaction */
70+
$transaction = $this->dataFactory->create();
71+
$this->resource->load($transaction, $entityId);
72+
return $transaction;
6973
}
7074

7175
/**
7276
* @inheritDoc
77+
* @return PaymentTransactionDataModel
7378
*/
7479
public function getByOrderId(int $orderId): PaymentTransactionDataInterface
7580
{
@@ -79,12 +84,16 @@ public function getByOrderId(int $orderId): PaymentTransactionDataInterface
7984
} elseif (!$this->resource->isOrderIdExists($orderId)) {
8085
throw new NoSuchEntityException(__('No record found for OrderID: %1.', $orderId));
8186
}
82-
return $this->dataFactory->create()
83-
->load($orderId, 'order_id');
87+
88+
/** @var PaymentTransactionDataModel $transaction */
89+
$transaction = $this->dataFactory->create();
90+
$this->resource->load($transaction, $orderId, 'order_id');
91+
return $transaction;
8492
}
8593

8694
/**
8795
* @inheritDoc
96+
* @return PaymentTransactionDataModel
8897
*/
8998
public function getByPaymentUuid(string $uuid): PaymentTransactionDataInterface
9099
{
@@ -95,12 +104,17 @@ public function getByPaymentUuid(string $uuid): PaymentTransactionDataInterface
95104
throw new NoSuchEntityException(__('No record found for uuid: %1.', $uuid));
96105
}
97106

98-
return $this->dataFactory->create()
99-
->load($uuid, 'uuid');
107+
$transaction = $this->dataFactory->create();
108+
/** @var PaymentTransactionDataModel $transaction */
109+
$this->resource->load($transaction, $uuid, 'uuid');
110+
return $transaction;
111+
100112
}
101113

102114
/**
103115
* @inheritDoc
116+
* @param PaymentTransactionDataModel $entity
117+
* @return PaymentTransactionDataModel
104118
*/
105119
public function save(PaymentTransactionDataInterface $entity): PaymentTransactionDataInterface
106120
{

Model/Transaction/Refund/RefundCollection.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
1111

12+
/**
13+
* @method RefundTransactionDataModel getFirstItem()
14+
*/
1215
class RefundCollection extends AbstractCollection
1316
{
1417
/**

Model/Transaction/Refund/RefundTransactionRepository.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public function getByCreditMemoId(int $id): RefundTransactionDataInterface
100100

101101
/**
102102
* @inheritDoc
103+
* @param \TrueLayer\Connect\Model\Transaction\Refund\RefundTransactionDataModel $entity
103104
*/
104105
public function save(RefundTransactionDataInterface $entity): RefundTransactionDataInterface
105106
{
@@ -116,13 +117,14 @@ public function save(RefundTransactionDataInterface $entity): RefundTransactionD
116117
/**
117118
* @param string $col
118119
* @param $value
119-
* @return RefundTransactionDataInterface
120+
* @return RefundTransactionDataModel
120121
* @throws NoSuchEntityException
121122
*/
122123
private function getByColumn(string $col, $value): RefundTransactionDataInterface
123124
{
124-
/** @var RefundTransactionDataInterface $transaction */
125-
$transaction = $this->dataFactory->create()->load($value, $col);
125+
/** @var RefundTransactionDataModel $transaction */
126+
$transaction = $this->dataFactory->create();
127+
$this->resource->load($transaction, $value, $col);
126128

127129
if (!$transaction->getEntityId()) {
128130
$this->logger->error('Refund transaction not found', $value);
@@ -135,10 +137,11 @@ private function getByColumn(string $col, $value): RefundTransactionDataInterfac
135137
/**
136138
* @param array $cols
137139
* @param array $sort
138-
* @return RefundTransactionDataInterface
140+
* @return RefundTransactionDataModel
139141
*/
140142
public function getOneByColumns(array $cols, array $sort = []): RefundTransactionDataInterface
141143
{
144+
142145
$collection = $this->collectionFactory->create();
143146

144147
foreach ($cols as $col => $value) {

Model/Ui/ConfigProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function __construct(
3030
/**
3131
* Get config
3232
*
33-
* @return \array[][]
33+
* @return array{payment:array{truelayer:array{description:string|null}}}
3434
*/
3535
public function getConfig(): array
3636
{

Model/User/ResourceModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function set(string $email, string $userId): bool
5555
}
5656

5757
/**
58-
* @param string $uuid
58+
* @param string $userId
5959
* @return mixed
6060
*/
6161
public function getByTruelayerId(string $userId)

Plugin/Payment/MethodList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(
3232
/**
3333
* @param Subject $subject
3434
* @param $availableMethods
35-
* @param CartInterface|null $quote
35+
* @param \Magento\Quote\Model\Quote|null $quote
3636
* @return mixed
3737
*/
3838
public function afterGetAvailableMethods(

0 commit comments

Comments
 (0)