2021-04-16 14:04:30 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2021-04-20 11:20:34 +02:00
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
2022-01-17 10:59:18 +01:00
|
|
|
*
|
2021-04-20 11:20:34 +02:00
|
|
|
* https://www.d3data.de
|
2021-04-16 14:04:30 +02:00
|
|
|
*
|
|
|
|
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
2021-04-20 11:20:34 +02:00
|
|
|
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
|
|
|
* @link https://www.oxidmodule.com
|
2021-04-16 14:04:30 +02:00
|
|
|
*/
|
|
|
|
|
2021-04-20 09:57:44 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2021-04-16 14:04:30 +02:00
|
|
|
namespace D3\DataWizard\Application\Controller\Admin;
|
|
|
|
|
|
|
|
use D3\DataWizard\Application\Model\Configuration;
|
2024-03-15 11:42:23 +01:00
|
|
|
use D3\DataWizard\Application\Model\Constants;
|
2021-04-20 09:50:49 +02:00
|
|
|
use D3\DataWizard\Application\Model\Exceptions\DataWizardException;
|
|
|
|
use D3\DataWizard\Application\Model\Exceptions\DebugException;
|
2021-11-03 10:16:39 +01:00
|
|
|
use D3\DataWizard\Application\Model\Exceptions\NoSuitableRendererException;
|
2021-04-20 16:18:40 +02:00
|
|
|
use D3\ModCfg\Application\Model\d3database;
|
2021-04-20 09:50:49 +02:00
|
|
|
use D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception;
|
|
|
|
use D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException;
|
2024-03-04 13:57:10 +01:00
|
|
|
use Doctrine\DBAL\Driver\Exception;
|
|
|
|
use Doctrine\DBAL\Exception as DBALException;
|
2021-04-16 14:04:30 +02:00
|
|
|
use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController;
|
2021-11-26 23:16:32 +01:00
|
|
|
use OxidEsales\Eshop\Core\Config;
|
2021-04-20 09:50:49 +02:00
|
|
|
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
|
|
|
|
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
|
2021-04-16 23:19:28 +02:00
|
|
|
use OxidEsales\Eshop\Core\Exception\StandardException;
|
2021-04-16 14:04:30 +02:00
|
|
|
use OxidEsales\Eshop\Core\Registry;
|
2024-03-04 13:57:10 +01:00
|
|
|
use Psr\Container\ContainerExceptionInterface;
|
|
|
|
use Psr\Container\NotFoundExceptionInterface;
|
2021-04-16 14:04:30 +02:00
|
|
|
|
|
|
|
class d3ExportWizard extends AdminDetailsController
|
|
|
|
{
|
2024-03-15 11:42:23 +01:00
|
|
|
protected $_sThisTemplate = '@'. Constants::OXID_MODULE_ID .'/admin/d3ExportWizard';
|
2021-04-16 14:04:30 +02:00
|
|
|
|
2024-03-04 13:57:10 +01:00
|
|
|
protected Configuration $configuration;
|
2021-04-16 14:04:30 +02:00
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
$this->configuration = oxNew(Configuration::class);
|
|
|
|
}
|
|
|
|
|
2023-05-23 10:59:44 +02:00
|
|
|
public function getViewId()
|
|
|
|
{
|
|
|
|
return 'd3mxDataWizard_Export';
|
|
|
|
}
|
|
|
|
|
2021-12-20 13:41:24 +01:00
|
|
|
public function getGroups(): array
|
2021-04-16 14:04:30 +02:00
|
|
|
{
|
2021-06-22 13:26:51 +02:00
|
|
|
return $this->configuration->getExportGroups();
|
2021-04-16 14:04:30 +02:00
|
|
|
}
|
|
|
|
|
2024-03-15 11:42:23 +01:00
|
|
|
public function getGroupTasks($group): array
|
2021-04-16 14:04:30 +02:00
|
|
|
{
|
|
|
|
return $this->configuration->getExportsByGroup($group);
|
|
|
|
}
|
|
|
|
|
2021-04-18 23:17:48 +02:00
|
|
|
/**
|
2024-03-04 13:57:10 +01:00
|
|
|
* @throws ContainerExceptionInterface
|
2021-04-20 09:50:49 +02:00
|
|
|
* @throws DatabaseConnectionException
|
2024-03-04 13:57:10 +01:00
|
|
|
* @throws Exception
|
|
|
|
* @throws NotFoundExceptionInterface
|
2021-04-20 09:50:49 +02:00
|
|
|
* @throws StandardException
|
|
|
|
* @throws d3ShopCompatibilityAdapterException
|
|
|
|
* @throws d3_cfg_mod_exception
|
2021-04-18 23:17:48 +02:00
|
|
|
*/
|
2024-03-04 13:57:10 +01:00
|
|
|
public function runTask(): void
|
2021-04-16 14:04:30 +02:00
|
|
|
{
|
2021-04-18 23:17:48 +02:00
|
|
|
try {
|
2021-11-03 10:16:39 +01:00
|
|
|
$this->execute();
|
|
|
|
} catch (DataWizardException|DBALException|DatabaseErrorException $e) {
|
|
|
|
Registry::getLogger()->error($e->getMessage());
|
|
|
|
Registry::getUtilsView()->addErrorToDisplay($e);
|
|
|
|
}
|
|
|
|
}
|
2021-04-16 23:19:28 +02:00
|
|
|
|
2021-11-03 10:16:39 +01:00
|
|
|
/**
|
|
|
|
* @throws DBALException
|
|
|
|
* @throws DatabaseConnectionException
|
|
|
|
* @throws DatabaseErrorException
|
|
|
|
* @throws NoSuitableRendererException
|
2024-03-04 13:57:10 +01:00
|
|
|
* @throws StandardException
|
|
|
|
* @throws Exception
|
|
|
|
* @throws ContainerExceptionInterface
|
|
|
|
* @throws NotFoundExceptionInterface
|
2021-11-03 10:16:39 +01:00
|
|
|
* @throws d3ShopCompatibilityAdapterException
|
|
|
|
* @throws d3_cfg_mod_exception
|
|
|
|
*/
|
2024-03-04 13:57:10 +01:00
|
|
|
protected function execute(): void
|
2021-11-03 10:16:39 +01:00
|
|
|
{
|
|
|
|
$id = Registry::getRequest()->getRequestEscapedParameter('taskid');
|
|
|
|
$export = $this->configuration->getExportById($id);
|
2021-04-20 16:18:40 +02:00
|
|
|
|
2021-11-03 10:16:39 +01:00
|
|
|
[ $queryString, $parameters ] = $export->getQuery();
|
2021-04-18 23:17:48 +02:00
|
|
|
|
2021-11-26 23:16:32 +01:00
|
|
|
if ($this->d3GetConfig()->getConfigParam('d3datawizard_debug')) {
|
2021-11-03 10:16:39 +01:00
|
|
|
throw oxNew(
|
|
|
|
DebugException::class,
|
|
|
|
d3database::getInstance()->getPreparedStatementQuery($queryString, $parameters)
|
|
|
|
);
|
2021-04-18 23:17:48 +02:00
|
|
|
}
|
2021-11-03 10:16:39 +01:00
|
|
|
|
|
|
|
$export->run(Registry::getRequest()->getRequestEscapedParameter('format'));
|
2021-04-16 14:04:30 +02:00
|
|
|
}
|
|
|
|
|
2021-11-26 23:16:32 +01:00
|
|
|
/**
|
|
|
|
* @return Config
|
|
|
|
*/
|
2021-12-20 13:41:24 +01:00
|
|
|
public function d3GetConfig(): Config
|
2021-11-26 23:16:32 +01:00
|
|
|
{
|
|
|
|
return Registry::getConfig();
|
|
|
|
}
|
|
|
|
|
2024-03-04 13:57:10 +01:00
|
|
|
public function getUserMessages(): ?string
|
2021-04-16 14:04:30 +02:00
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2024-03-04 13:57:10 +01:00
|
|
|
public function getHelpURL(): ?string
|
2021-04-16 14:04:30 +02:00
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
2022-01-17 10:59:18 +01:00
|
|
|
}
|