refactor: wydzielenie ApiloRepository z IntegrationsRepository
IntegrationsRepository zredukowany z ~875 do ~340 linii. Nowa klasa ApiloRepository przejmuje 19 metod apilo*. Konsumenci (IntegrationsController, OrderAdminService, cron.php) zaktualizowani przez DI. Suite: 818 testów, 2275 asercji. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,15 +2,18 @@
|
||||
namespace admin\Controllers;
|
||||
|
||||
use Domain\Integrations\IntegrationsRepository;
|
||||
use Domain\Integrations\ApiloRepository;
|
||||
use admin\ViewModels\Common\PaginatedTableViewModel;
|
||||
|
||||
class IntegrationsController
|
||||
{
|
||||
private IntegrationsRepository $repository;
|
||||
private ApiloRepository $apiloRepository;
|
||||
|
||||
public function __construct( IntegrationsRepository $repository )
|
||||
public function __construct( IntegrationsRepository $repository, ApiloRepository $apiloRepository )
|
||||
{
|
||||
$this->repository = $repository;
|
||||
$this->apiloRepository = $apiloRepository;
|
||||
}
|
||||
|
||||
public function logs(): string
|
||||
@@ -125,7 +128,7 @@ class IntegrationsController
|
||||
{
|
||||
return \Shared\Tpl\Tpl::view( 'integrations/apilo-settings', [
|
||||
'settings' => $this->repository->getSettings( 'apilo' ),
|
||||
'apilo_status' => $this->repository->apiloIntegrationStatus(),
|
||||
'apilo_status' => $this->apiloRepository->apiloIntegrationStatus(),
|
||||
] );
|
||||
}
|
||||
|
||||
@@ -147,7 +150,7 @@ class IntegrationsController
|
||||
{
|
||||
$settings = $this->repository->getSettings( 'apilo' );
|
||||
|
||||
if ( $this->repository->apiloAuthorize(
|
||||
if ( $this->apiloRepository->apiloAuthorize(
|
||||
(string)($settings['client-id'] ?? ''),
|
||||
(string)($settings['client-secret'] ?? ''),
|
||||
(string)($settings['authorization-code'] ?? '')
|
||||
@@ -156,7 +159,7 @@ class IntegrationsController
|
||||
exit;
|
||||
}
|
||||
|
||||
$status = $this->repository->apiloIntegrationStatus();
|
||||
$status = $this->apiloRepository->apiloIntegrationStatus();
|
||||
$message = trim( (string)($status['message'] ?? '') );
|
||||
if ( $message === '' ) {
|
||||
$message = 'Podczas autoryzacji wystapil blad. Prosze sprawdzic dane i sprobowac ponownie.';
|
||||
@@ -191,7 +194,7 @@ class IntegrationsController
|
||||
public function apilo_create_product(): void
|
||||
{
|
||||
$productId = (int) \Shared\Helpers\Helpers::get( 'product_id' );
|
||||
$result = $this->repository->apiloCreateProduct( $productId );
|
||||
$result = $this->apiloRepository->apiloCreateProduct( $productId );
|
||||
|
||||
\Shared\Helpers\Helpers::alert( (string)($result['message'] ?? 'Wystapil blad podczas tworzenia produktu w Apilo.') );
|
||||
header( 'Location: /admin/shop_product/view_list/' );
|
||||
@@ -208,7 +211,7 @@ class IntegrationsController
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode( $this->repository->apiloProductSearch( $sku ) );
|
||||
echo json_encode( $this->apiloRepository->apiloProductSearch( $sku ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -267,7 +270,7 @@ class IntegrationsController
|
||||
|
||||
private function fetchApiloListWithFeedback( string $type, string $label ): void
|
||||
{
|
||||
$result = $this->repository->apiloFetchListResult( $type );
|
||||
$result = $this->apiloRepository->apiloFetchListResult( $type );
|
||||
|
||||
if ( !empty( $result['success'] ) ) {
|
||||
$count = (int)($result['count'] ?? 0);
|
||||
|
||||
Reference in New Issue
Block a user