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

118 Zeilen
3.5 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;
2024-03-15 11:42:23 +01:00
use D3\DataWizard\Application\Model\Constants;
2021-05-05 23:20:42 +02:00
use D3\DataWizard\Application\Model\Exceptions\DataWizardException;
use D3\DataWizard\Application\Model\Exceptions\DebugException;
2024-03-04 13:57:10 +01:00
use D3\DataWizard\Application\Model\Exceptions\InputUnvalidException;
use D3\DataWizard\Application\Model\Exceptions\TaskException;
2021-05-05 23:20:42 +02:00
use D3\ModCfg\Application\Model\d3database;
2024-03-04 13:57:10 +01:00
use Doctrine\DBAL\Exception as DBALException;
2021-05-05 23:20:42 +02:00
use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController;
use OxidEsales\Eshop\Core\Registry;
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
2024-03-04 13:57:10 +01:00
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
2021-05-05 23:20:42 +02:00
class d3ActionWizard extends AdminDetailsController
{
2024-03-15 11:42:23 +01:00
protected $_sThisTemplate = '@'. Constants::OXID_MODULE_ID .'/admin/d3ActionWizard';
2021-05-05 23:20:42 +02:00
2024-03-04 13:57:10 +01:00
protected Configuration $configuration;
2021-05-05 23:20:42 +02:00
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
}
2024-03-15 11:42:23 +01:00
public function getGroupTasks($group): array
2021-05-05 23:20:42 +02:00
{
return $this->configuration->getActionsByGroup($group);
}
/**
2024-03-04 13:57:10 +01:00
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
2021-05-05 23:20:42 +02:00
*/
2024-03-04 13:57:10 +01:00
public function runTask(): void
2021-05-05 23:20:42 +02:00
{
try {
$this->execute();
2024-03-04 13:57:10 +01:00
} catch (DataWizardException|DBALException $e) {
Registry::getLogger()->error($e->getMessage());
Registry::getUtilsView()->addErrorToDisplay($e);
}
}
2021-05-05 23:20:42 +02:00
/**
2024-03-04 13:57:10 +01:00
* @throws ContainerExceptionInterface
* @throws DBALException
* @throws DebugException
* @throws InputUnvalidException
* @throws NotFoundExceptionInterface
* @throws TaskException
*/
2024-03-04 13:57:10 +01:00
protected function execute(): void
{
$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
if ($this->getSettingsService()->getBoolean('d3datawizard_debug', Constants::OXID_MODULE_ID)) {
2024-03-04 13:57:10 +01:00
/** @var DebugException $debug */
$debug = oxNew(
DebugException::class,
d3database::getInstance()->getPreparedStatementQuery($queryString, $parameters)
);
2024-03-04 13:57:10 +01:00
throw $debug;
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 ModuleSettingService
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
2021-11-26 23:16:32 +01:00
*/
public function getSettingsService(): ModuleSettingServiceInterface
2021-11-26 23:16:32 +01:00
{
return ContainerFactory::getInstance()->getContainer()->get(ModuleSettingServiceInterface::class);
2021-11-26 23:16:32 +01:00
}
2024-03-04 13:57:10 +01:00
public function getUserMessages(): ?string
2021-05-05 23:20:42 +02:00
{
return null;
}
2024-03-04 13:57:10 +01:00
public function getHelpURL(): ?string
2021-05-05 23:20:42 +02:00
{
return null;
}
2022-01-17 10:59:18 +01:00
}