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.
|
|
|
|
*
|
|
|
|
* 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\Model;
|
|
|
|
|
2021-06-22 13:26:51 +02:00
|
|
|
use D3\DataWizard\Application\Model\Actions\FixArtextendsItems;
|
2021-06-25 15:33:57 +02:00
|
|
|
use D3\DataWizard\Application\Model\Exceptions\DataWizardException;
|
2021-04-27 23:40:54 +02:00
|
|
|
use D3\DataWizard\Application\Model\Exports\InactiveCategories;
|
2021-04-28 13:39:03 +02:00
|
|
|
use D3\DataWizard\Application\Model\Exports\KeyFigures;
|
2021-04-27 23:51:12 +02:00
|
|
|
use OxidEsales\Eshop\Core\Registry;
|
2021-04-27 23:40:54 +02:00
|
|
|
|
2021-04-16 14:04:30 +02:00
|
|
|
class Configuration
|
|
|
|
{
|
2021-04-28 13:40:04 +02:00
|
|
|
const GROUP_SHOP = 'D3_DATAWIZARD_GROUP_SHOP';
|
2021-04-16 14:04:30 +02:00
|
|
|
const GROUP_CATEGORY = 'D3_DATAWIZARD_GROUP_CATEGORIES';
|
|
|
|
const GROUP_ARTICLES = 'D3_DATAWIZARD_GROUP_ARTICLES';
|
2021-04-16 23:19:28 +02:00
|
|
|
const GROUP_USERS = 'D3_DATAWIZARD_GROUP_USERS';
|
|
|
|
const GROUP_ORDERS = 'D3_DATAWIZARD_GROUP_ORDERS';
|
2021-04-16 14:04:30 +02:00
|
|
|
const GROUP_REMARKS = 'D3_DATAWIZARD_GROUP_REMARKS';
|
2021-07-27 15:15:21 +02:00
|
|
|
const GROUP_CMS = 'D3_DATAWIZARD_GROUP_CMS';
|
2021-04-16 14:04:30 +02:00
|
|
|
|
2021-05-05 23:20:42 +02:00
|
|
|
protected $actions = [];
|
2021-04-16 14:04:30 +02:00
|
|
|
protected $exports = [];
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->configure();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function configure()
|
|
|
|
{
|
2021-07-27 15:15:21 +02:00
|
|
|
// extend to add exports and actions via 'registerAction()' or 'registerExport()' method
|
2021-04-16 14:04:30 +02:00
|
|
|
}
|
|
|
|
|
2021-05-05 23:20:42 +02:00
|
|
|
/**
|
|
|
|
* @param $group
|
|
|
|
* @param ActionBase $action
|
|
|
|
*/
|
|
|
|
public function registerAction($group, ActionBase $action)
|
|
|
|
{
|
2021-06-25 15:33:57 +02:00
|
|
|
$this->actions[$group][md5(get_class($action))] = $action;
|
2021-05-05 23:20:42 +02:00
|
|
|
}
|
|
|
|
|
2021-04-20 09:50:49 +02:00
|
|
|
/**
|
|
|
|
* @param $group
|
|
|
|
* @param ExportBase $export
|
|
|
|
*/
|
2021-04-16 14:04:30 +02:00
|
|
|
public function registerExport($group, ExportBase $export)
|
|
|
|
{
|
2021-06-25 15:33:57 +02:00
|
|
|
$this->exports[$group][md5(get_class($export))] = $export;
|
2021-04-16 14:04:30 +02:00
|
|
|
}
|
|
|
|
|
2021-05-05 23:20:42 +02:00
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getGroupedActions(): array
|
|
|
|
{
|
|
|
|
return $this->actions;
|
|
|
|
}
|
|
|
|
|
2021-04-20 09:50:49 +02:00
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getGroupedExports(): array
|
2021-04-16 14:04:30 +02:00
|
|
|
{
|
|
|
|
return $this->exports;
|
|
|
|
}
|
|
|
|
|
2021-04-20 09:50:49 +02:00
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2021-06-22 13:26:51 +02:00
|
|
|
public function getActionGroups(): array
|
|
|
|
{
|
|
|
|
return array_keys($this->actions);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getExportGroups(): array
|
2021-04-16 14:04:30 +02:00
|
|
|
{
|
|
|
|
return array_keys($this->exports);
|
|
|
|
}
|
|
|
|
|
2021-06-22 13:26:51 +02:00
|
|
|
/**
|
|
|
|
* @param $group
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2021-05-05 23:20:42 +02:00
|
|
|
public function getActionsByGroup($group)
|
|
|
|
{
|
|
|
|
return $this->actions[$group];
|
|
|
|
}
|
|
|
|
|
2021-06-22 13:26:51 +02:00
|
|
|
/**
|
|
|
|
* @param $group
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2021-04-16 14:04:30 +02:00
|
|
|
public function getExportsByGroup($group)
|
|
|
|
{
|
|
|
|
return $this->exports[$group];
|
|
|
|
}
|
|
|
|
|
2021-05-05 23:20:42 +02:00
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getAllActions() : array
|
|
|
|
{
|
|
|
|
$all = [];
|
|
|
|
|
2021-06-22 13:26:51 +02:00
|
|
|
foreach ($this->getActionGroups() as $group) {
|
2021-05-05 23:20:42 +02:00
|
|
|
$all = array_merge($all, $this->getActionsByGroup($group));
|
|
|
|
}
|
|
|
|
|
|
|
|
return $all;
|
|
|
|
}
|
|
|
|
|
2021-04-16 14:04:30 +02:00
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getAllExports() : array
|
|
|
|
{
|
|
|
|
$all = [];
|
|
|
|
|
2021-06-22 13:26:51 +02:00
|
|
|
foreach ($this->getExportGroups() as $group) {
|
2021-04-16 14:04:30 +02:00
|
|
|
$all = array_merge($all, $this->getExportsByGroup($group));
|
|
|
|
}
|
|
|
|
|
|
|
|
return $all;
|
|
|
|
}
|
|
|
|
|
2021-05-05 23:20:42 +02:00
|
|
|
/**
|
|
|
|
* @param $id
|
|
|
|
*
|
|
|
|
* @return ActionBase
|
|
|
|
*/
|
|
|
|
public function getActionById($id) : ActionBase
|
|
|
|
{
|
2021-11-28 01:04:46 +01:00
|
|
|
$allActions = $this->getAllActions();
|
|
|
|
|
|
|
|
if (false == $allActions[$id]) {
|
|
|
|
throw oxNew(DataWizardException::class, 'no action with id '.$id);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $allActions[$id];
|
2021-05-05 23:20:42 +02:00
|
|
|
}
|
|
|
|
|
2021-04-16 14:04:30 +02:00
|
|
|
/**
|
|
|
|
* @param $id
|
|
|
|
*
|
|
|
|
* @return ExportBase
|
|
|
|
*/
|
|
|
|
public function getExportById($id) : ExportBase
|
|
|
|
{
|
2021-06-25 15:33:57 +02:00
|
|
|
$allExports = $this->getAllExports();
|
|
|
|
|
|
|
|
if (false == $allExports[$id]) {
|
|
|
|
throw oxNew(DataWizardException::class, 'no export with id '.$id);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $allExports[$id];
|
2021-04-16 14:04:30 +02:00
|
|
|
}
|
2021-05-05 23:20:42 +02:00
|
|
|
}
|