From 75506424c5dca88edd1f3480a18f1496883404a4 Mon Sep 17 00:00:00 2001 From: Thomas Zilio Date: Fri, 29 Nov 2019 18:44:08 +0100 Subject: [PATCH] Update Interaction.php --- plugins/importFE/src/Interaction.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/plugins/importFE/src/Interaction.php b/plugins/importFE/src/Interaction.php index da1e99cba..6622aa724 100644 --- a/plugins/importFE/src/Interaction.php +++ b/plugins/importFE/src/Interaction.php @@ -16,15 +16,12 @@ class Interaction extends Services $list = self::getRemoteList(); // Ricerca fisica - $names = array_column($list, 'name'); - $files = self::getFileList($names); - - $list = array_merge($list, $files); + $result = self::getFileList($list); // Aggiornamento cache hook - InvoiceHook::update($list); + InvoiceHook::update($result); - return $list; + return $result; } public static function getRemoteList() @@ -42,9 +39,9 @@ class Interaction extends Services return $list ?: []; } - public static function getFileList($names = []) + public static function getFileList($list = []) { - $list = []; + $names = array_column($list, 'name'); // Ricerca fisica $directory = FatturaElettronica::getImportDirectory(); @@ -52,13 +49,16 @@ class Interaction extends Services $files = glob($directory.'/*.xml*'); foreach ($files as $id => $file) { $name = basename($file); + $pos = array_search($name, $names); - if (!in_array($name, $names)) { + if ($pos === false) { $list[] = [ 'id' => $id, 'name' => $name, 'file' => true, ]; + } else { + $list[$pos]['id'] = $id; } }