connect(); $timeStart = microtime(true); // DRS sklad synchronizujeme pouze na pompu if ($this->configuration->isPompo()) { // Sesynchronizuju DRS sklad - sklad prodejen $this->synchronize(function () use ($output) { $output->writeln('Synchronizing DRS stock...'); $this->pompoUtil->synchronizeDRS([DRSStockSynchronizer::getType()]); $output->writeln('DRS Stock changes synchronized'); }, $output); } // Sesynchronizuju DataGo sklad - hlavni sklad $this->synchronize(function () use ($output) { $output->writeln('Synchronizing DataGo stock...'); $this->pompoUtil->synchronizeDataGo([DataGoStockSynchronizer::getType()]); $output->writeln('DataGo Stock changes synchronized'); }, $output); $executionTime = (int) (microtime(true) - $timeStart); sqlGetConnection()->close(); $sleep = max((int) ($interval - $executionTime), 0); $output->writeln(sprintf('Sleeping for %s seconds...', $sleep)); sleep($sleep); } } private function synchronize(callable $callable, OutputInterface $output): void { try { $callable(); } catch (\Throwable $e) { if (isDevelopment()) { throw $e; } $this->sentryLogger->captureException($e); $output->writeln(sprintf('Some error occurred during dispatch: %s', $e->getMessage())); } } }