diff --git a/Interfaces/GSD/Importer.php b/Interfaces/GSD/Importer.php index 5562a11..0e99b16 100755 --- a/Interfaces/GSD/Importer.php +++ b/Interfaces/GSD/Importer.php @@ -74,14 +74,6 @@ use phpOMS\Utils\IO\Zip\Zip; */ final class Importer extends ImporterAbstract { - /** - * Database connection. - * - * @var ConnectionAbstract - * @since 1.0.0 - */ - private ConnectionAbstract $remote; - /** * Account * @@ -465,7 +457,7 @@ final class Importer extends ImporterAbstract $media[$number] = new Media(); $media[$number]->name = (string) $number; - $media[$number]->type = 'backend_image'; + $media[$number]->type = null; $media[$number]->setPath('/Modules/Media/Files/Modules/ItemManagement/Articles/Images/' . $image); $media[$number]->setVirtualPath('/Modules/ItemManagement/Articles/Images'); $media[$number]->extension = \explode('.', $image)[1]; diff --git a/Interfaces/Intrexx/Importer.php b/Interfaces/Intrexx/Importer.php index 3c1cbc6..1bdfece 100755 --- a/Interfaces/Intrexx/Importer.php +++ b/Interfaces/Intrexx/Importer.php @@ -32,7 +32,7 @@ final class Importer extends ImporterAbstract * * @param RequestAbstract $request Request * - * @return bool + * @return array * * @since 1.0.0 */ diff --git a/Interfaces/OMS/Exporter.php b/Interfaces/OMS/Exporter.php index e3441cf..6cdb878 100755 --- a/Interfaces/OMS/Exporter.php +++ b/Interfaces/OMS/Exporter.php @@ -17,6 +17,7 @@ namespace Modules\Exchange\Interfaces\OMS; use Modules\Exchange\Models\ExchangeLog; use Modules\Exchange\Models\ExchangeType; use Modules\Exchange\Models\ExporterAbstract; +use phpOMS\Localization\L11nManager; use phpOMS\DataStorage\Database\Connection\ConnectionAbstract; use phpOMS\Message\RequestAbstract; use phpOMS\Utils\StringUtils; @@ -31,14 +32,6 @@ use phpOMS\Utils\StringUtils; */ final class Exporter extends ExporterAbstract { - /** - * Database connection. - * - * @var ConnectionAbstract - * @since 1.0.0 - */ - private ConnectionAbstract $remote; - /** * Account * @@ -48,16 +41,12 @@ final class Exporter extends ExporterAbstract private int $account = 1; /** - * Constructor - * - * @param ConnectionAbstract $local Database connection - * - * @since 1.0.0 + * {@inheritdoc} */ - public function __construct(ConnectionAbstract $local) + public function __construct(ConnectionAbstract $local, L11nManager $l11n) { - $this->local = $local; - $this->app->l11nManager->loadLanguageFile('Exchange', __DIR__ . '/Lang/lang.php'); + parent::__construct($local, $l11n); + $this->l11n->loadLanguageFile('Exchange', __DIR__ . '/Lang/lang.php'); } /** @@ -72,7 +61,7 @@ final class Exporter extends ExporterAbstract */ public function export(\DateTime $start, \DateTime $end) : void { - $this->exportLanguage($start, $end); + $this->exportLanguage(); } /** @@ -91,13 +80,15 @@ final class Exporter extends ExporterAbstract $this->account = $request->header->account; + $result = []; + if ($request->getData('type') === 'language') { $result = $this->exportLanguage(); $log = new ExchangeLog(); $log->createdBy = $this->account; $log->setType(ExchangeType::EXPORT); - $log->message = $this->app->l11nManager->getText($request->header->l11n->getLanguage(), 'Exchange', '', 'LangFileExported'); + $log->message = $this->l11n->getText($request->header->l11n->getLanguage(), 'Exchange', '', 'LangFileExported'); $log->subtype = 'language'; $log->exchange = (int) $request->getData('id'); @@ -214,6 +205,11 @@ final class Exporter extends ExporterAbstract $template = \file_get_contents($item->getPathname()); $keys = []; + + if ($template === false) { + continue; // @codeCoverageIgnore + } + \preg_match_all('/(\$this\->getHtml\(\')([0-9a-zA-Z:]+)(\'\))/', $template, $keys, \PREG_PATTERN_ORDER); foreach ($keys[2] ?? [] as $key) { diff --git a/Interfaces/OMS/Importer.php b/Interfaces/OMS/Importer.php index 97698cf..95edf84 100755 --- a/Interfaces/OMS/Importer.php +++ b/Interfaces/OMS/Importer.php @@ -16,6 +16,7 @@ namespace Modules\Exchange\Interfaces\OMS; use Modules\Exchange\Models\ExchangeLog; use Modules\Exchange\Models\ExchangeType; +use phpOMS\Localization\L11nManager; use Modules\Exchange\Models\ImporterAbstract; use Modules\Media\Controller\ApiController; use phpOMS\DataStorage\Database\Connection\ConnectionAbstract; @@ -34,14 +35,6 @@ use phpOMS\Message\RequestAbstract; */ final class Importer extends ImporterAbstract { - /** - * Database connection. - * - * @var ConnectionAbstract - * @since 1.0.0 - */ - private ConnectionAbstract $remote; - /** * Account * @@ -51,16 +44,12 @@ final class Importer extends ImporterAbstract private int $account = 1; /** - * Constructor - * - * @param ConnectionAbstract $local Database connection - * - * @since 1.0.0 + * {@inheritdoc} */ - public function __construct(ConnectionAbstract $local) + public function __construct(ConnectionAbstract $local, ConnectionAbstract $remote, L11nManager $l11n) { - $this->local = $local; - $this->app->l11nManager->loadLanguageFile('Exchange', __DIR__ . '/Lang/lang.php'); + parent::__construct($local, $remote, $l11n); + $this->l11n->loadLanguageFile('Exchange', __DIR__ . '/Lang/lang.php'); } /** @@ -119,7 +108,7 @@ final class Importer extends ImporterAbstract $log = new ExchangeLog(); $log->createdBy = $this->account; $log->setType(ExchangeType::IMPORT); - $log->message = $this->app->l11nManager->getText($request->header->l11n->getLanguage(), 'Exchange', '', 'LangFileImported'); + $log->message = $this->l11n->getText($request->header->l11n->getLanguage(), 'Exchange', '', 'LangFileImported'); $log->subtype = 'language'; $log->exchange = (int) $request->getData('id'); @@ -147,6 +136,10 @@ final class Importer extends ImporterAbstract $header = \fgetcsv($fp, 0, ';', '"'); + if ($header === false) { + return; // @codeCoverageIgnore + } + $languageArray = []; $supportedLanguages = \array_slice($header, 4); $keyLengths = []; diff --git a/Models/ExporterAbstract.php b/Models/ExporterAbstract.php index bbd0326..29921a5 100755 --- a/Models/ExporterAbstract.php +++ b/Models/ExporterAbstract.php @@ -15,6 +15,7 @@ declare(strict_types=1); namespace Modules\Exchange\Models; use phpOMS\DataStorage\Database\Connection\ConnectionAbstract; +use phpOMS\Localization\L11nManager; use phpOMS\Message\RequestAbstract; /** @@ -35,16 +36,26 @@ abstract class ExporterAbstract */ protected ConnectionAbstract $local; + /** + * L11n manager. + * + * @var L11nManager + * @since 1.0.0 + */ + protected L11nManager $l11n; + /** * Constructor * * @param ConnectionAbstract $local Database connection + * @param L11nManager $l11n Localization manager * * @since 1.0.0 */ - public function __construct(ConnectionAbstract $local) + public function __construct(ConnectionAbstract $local, L11nManager $l11n) { $this->local = $local; + $this->l11n = $l11n; } /** diff --git a/Models/ImporterAbstract.php b/Models/ImporterAbstract.php index 0d99a4e..5722702 100755 --- a/Models/ImporterAbstract.php +++ b/Models/ImporterAbstract.php @@ -15,6 +15,7 @@ declare(strict_types=1); namespace Modules\Exchange\Models; use phpOMS\DataStorage\Database\Connection\ConnectionAbstract; +use phpOMS\Localization\L11nManager; use phpOMS\Message\RequestAbstract; /** @@ -27,6 +28,14 @@ use phpOMS\Message\RequestAbstract; */ abstract class ImporterAbstract { + /** + * Database connection. + * + * @var ConnectionAbstract + * @since 1.0.0 + */ + protected ConnectionAbstract $remote; + /** * Database connection. * @@ -35,16 +44,28 @@ abstract class ImporterAbstract */ protected ConnectionAbstract $local; + /** + * L11n manager. + * + * @var L11nManager + * @since 1.0.0 + */ + protected L11nManager $l11n; + /** * Constructor * - * @param ConnectionAbstract $local Database connection + * @param ConnectionAbstract $local Database connection + * @param ConnectionAbstract $remote Database connection + * @param L11nManager $l11n Localization manager * * @since 1.0.0 */ - public function __construct(ConnectionAbstract $local) + public function __construct(ConnectionAbstract $local, ConnectionAbstract $remote, L11nManager $l11n) { $this->local = $local; + $this->remote = $remote; + $this->l11n = $l11n; } /**