8
0
DataWizard/Application/Controller/Admin/d3ActionWizard.php

105 Zeilen
2.7 KiB
PHP

2021-05-05 23:20:42 +02:00
<?php
/**
* 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-05-05 23:20:42 +02:00
* https://www.d3data.de
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
* @link https://www.oxidmodule.com
*/
declare(strict_types=1);
namespace D3\DataWizard\Application\Controller\Admin;
use D3\DataWizard\Application\Model\Configuration;
use D3\DataWizard\Application\Model\Exceptions\DataWizardException;
use D3\DataWizard\Application\Model\Exceptions\DebugException;
use D3\ModCfg\Application\Model\d3database;
use Doctrine\DBAL\DBALException;
use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController;
2021-11-26 23:16:32 +01:00
use OxidEsales\Eshop\Core\Config;
2021-05-05 23:20:42 +02:00
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
use OxidEsales\Eshop\Core\Registry;
class d3ActionWizard extends AdminDetailsController
{
protected $_sThisTemplate = 'd3ActionWizard.tpl';
/** @var Configuration */
protected $configuration;
public function __construct()
{
parent::__construct();
$this->configuration = oxNew(Configuration::class);
}
2021-12-20 13:41:24 +01:00
public function getGroups(): array
2021-05-05 23:20:42 +02:00
{
2021-06-22 13:26:51 +02:00
return $this->configuration->getActionGroups();
2021-05-05 23:20:42 +02:00
}
public function getGroupTasks($group)
2021-05-05 23:20:42 +02:00
{
return $this->configuration->getActionsByGroup($group);
}
/**
* @throws DatabaseConnectionException
*/
public function runTask()
2021-05-05 23:20:42 +02:00
{
try {
$this->execute();
} catch (DataWizardException|DBALException|DatabaseErrorException $e) {
Registry::getLogger()->error($e->getMessage());
Registry::getUtilsView()->addErrorToDisplay($e);
}
}
2021-05-05 23:20:42 +02:00
/**
* @throws DatabaseConnectionException
* @throws DatabaseErrorException
*/
protected function execute()
{
$id = Registry::getRequest()->getRequestEscapedParameter('taskid');
$action = $this->configuration->getActionById($id);
2021-05-05 23:20:42 +02:00
[ $queryString, $parameters ] = $action->getQuery();
2021-05-05 23:20:42 +02:00
2021-11-26 23:16:32 +01:00
if ($this->d3GetConfig()->getConfigParam('d3datawizard_debug')) {
throw oxNew(
DebugException::class,
d3database::getInstance()->getPreparedStatementQuery($queryString, $parameters)
);
2021-05-05 23:20:42 +02:00
}
$action->run();
2021-05-05 23:20:42 +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();
}
2021-05-05 23:20:42 +02:00
public function getUserMessages()
{
return null;
}
public function getHelpURL()
{
return null;
}
2022-01-17 10:59:18 +01:00
}