Skip to content

Commit

Permalink
handle the titles in the method directly
Browse files Browse the repository at this point in the history
  • Loading branch information
remyperona committed Nov 14, 2024
1 parent c7c0839 commit e07d104
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
15 changes: 10 additions & 5 deletions inc/Engine/Optimization/DynamicLists/DynamicLists.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,17 @@ public function update_lists_from_remote() {
$response = [];
$success = false;
$should_purge = false;
$titles = [

Check notice on line 108 in inc/Engine/Optimization/DynamicLists/DynamicLists.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Optimization/DynamicLists/DynamicLists.php#L108

Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space
'defaultlists' => __( 'Default Lists', 'rocket' ),
'delayjslists' => __( 'Delay JavaScript Execution Exclusion Lists', 'rocket' ),
'incompatible_plugins' => __( 'Incompatible plugins Lists', 'rocket' ),
];

Check notice on line 112 in inc/Engine/Optimization/DynamicLists/DynamicLists.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

inc/Engine/Optimization/DynamicLists/DynamicLists.php#L112

Tabs must be used to indent lines; spaces are not allowed

foreach ( $this->providers as $provider ) {
foreach ( $this->providers as $provider_id => $provider ) {
$result = $provider->api_client->get_exclusions_list( $provider->data_manager->get_lists_hash() );

if ( empty( $result['code'] ) || empty( $result['body'] ) ) {
$response[ $provider->title ] = [
$response[ $titles[ $provider_id ] ] = [
'success' => false,
'data' => '',
'message' => __( 'Could not get updated lists from server.', 'rocket' ),
Expand All @@ -119,7 +124,7 @@ public function update_lists_from_remote() {
}

if ( 206 === $result['code'] ) {
$response[ $provider->title ] = [
$response[ $titles[ $provider_id ] ] = [
'success' => true,
'data' => '',
'message' => __( 'Lists are up to date.', 'rocket' ),
Expand All @@ -128,7 +133,7 @@ public function update_lists_from_remote() {
}

if ( ! $provider->data_manager->save_dynamic_lists( $result['body'] ) ) {
$response[ $provider->title ] = [
$response[ $titles[ $provider_id ] ] = [
'success' => false,
'data' => '',
'message' => __( 'Could not update lists.', 'rocket' ),
Expand All @@ -137,7 +142,7 @@ public function update_lists_from_remote() {
}

$success = true;
$response[ $provider->title ] = [
$response[ $titles[ $provider_id ] ] = [
'success' => true,
'data' => '',
'message' => __( 'Lists are successfully updated.', 'rocket' ),
Expand Down
4 changes: 1 addition & 3 deletions inc/Engine/Optimization/DynamicLists/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,17 @@ public function register(): void {
(object) [
'api_client' => $this->getContainer()->get( 'dynamic_lists_defaultlists_api_client' ),
'data_manager' => $this->getContainer()->get( 'dynamic_lists_defaultlists_data_manager' ),
'title' => 'default-lists',
],
'delayjslists' =>
(object) [
'api_client' => $this->getContainer()->get( 'dynamic_lists_delayjslists_api_client' ),
'data_manager' => $this->getContainer()->get( 'dynamic_lists_delayjslists_data_manager' ),
'title' => 'delay-js-lists',
],
'incompatible_plugins' =>
(object) [
'api_client' => $this->getContainer()->get( 'dynamic_lists_incompatible_plugins_lists_api_client' ),
'data_manager' => $this->getContainer()->get( 'dynamic_lists_incompatible_plugins_lists_data_manager' ),
'title' => 'incompatible-plugins-lists',
'clear_cache' => false,
],
];

Expand Down

0 comments on commit e07d104

Please sign in to comment.