mirror of
https://github.com/Karaka-Management/oms-Support.git
synced 2026-01-11 00:58:41 +00:00
new datamapper mostly implemented
This commit is contained in:
parent
15c2ee9b91
commit
61693db2e6
|
|
@ -27,7 +27,7 @@ use phpOMS\DataStorage\Cookie\CookieJar;
|
|||
use phpOMS\DataStorage\Database\Connection\ConnectionAbstract;
|
||||
use phpOMS\DataStorage\Database\DatabasePool;
|
||||
use phpOMS\DataStorage\Database\DatabaseStatus;
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
use phpOMS\DataStorage\Session\HttpSession;
|
||||
use phpOMS\Dispatcher\Dispatcher;
|
||||
use phpOMS\Event\EventManager;
|
||||
|
|
@ -136,13 +136,13 @@ final class Application
|
|||
|
||||
/** @var ConnectionAbstract $con */
|
||||
$con = $this->app->dbPool->get();
|
||||
DataMapperAbstract::setConnection($con);
|
||||
DataMapperFactory::db($con);
|
||||
|
||||
$this->app->cachePool = new CachePool();
|
||||
$this->app->appSettings = new CoreSettings();
|
||||
$this->app->eventManager = new EventManager($this->app->dispatcher);
|
||||
$this->app->accountManager = new AccountManager($this->app->sessionManager);
|
||||
$this->app->l11nServer = LocalizationMapper::get(1);
|
||||
$this->app->l11nServer = LocalizationMapper::get()->where('id', 1)->execute();
|
||||
$this->app->orgId = $this->getApplicationOrganization($request, $this->config['app']);
|
||||
|
||||
$aid = Auth::authenticate($this->app->sessionManager);
|
||||
|
|
|
|||
|
|
@ -49,6 +49,6 @@ final class Installer extends InstallerAbstract
|
|||
$app = new SupportApp();
|
||||
$app->name = 'Backend';
|
||||
|
||||
$id = SupportAppMapper::create($app);
|
||||
$id = SupportAppMapper::create()->execute($app);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ use Modules\Support\Models\TicketElementMapper;
|
|||
use Modules\Support\Models\TicketMapper;
|
||||
use Modules\Tasks\Models\TaskStatus;
|
||||
use Modules\Tasks\Models\TaskType;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
use phpOMS\Message\Http\RequestStatusCode;
|
||||
use phpOMS\Message\NotificationLevel;
|
||||
use phpOMS\Message\RequestAbstract;
|
||||
|
|
@ -140,7 +141,7 @@ final class ApiController extends Controller
|
|||
*/
|
||||
public function apiTicketGet(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
||||
{
|
||||
$ticket = TicketMapper::get((int) $request->getData('id'));
|
||||
$ticket = TicketMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Ticket', 'Ticket successfully returned.', $ticket);
|
||||
}
|
||||
|
||||
|
|
@ -159,7 +160,7 @@ final class ApiController extends Controller
|
|||
*/
|
||||
public function apiTicketSet(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
||||
{
|
||||
$old = clone TicketMapper::get((int) $request->getData('id'));
|
||||
$old = clone TicketMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$new = $this->updateTicketFromRequest($request);
|
||||
$this->updateModel($request->header->account, $old, $new, TicketMapper::class, 'ticket', $request->getOrigin());
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Ticket', 'Ticket successfully updated.', $new);
|
||||
|
|
@ -176,7 +177,8 @@ final class ApiController extends Controller
|
|||
*/
|
||||
private function updateTicketFromRequest(RequestAbstract $request) : Ticket
|
||||
{
|
||||
$ticket = TicketMapper::get((int) ($request->getData('id')));
|
||||
/** @var Ticket $ticket */
|
||||
$ticket = TicketMapper::get()->where('id', (int) ($request->getData('id')))->execute();
|
||||
|
||||
return $ticket;
|
||||
}
|
||||
|
|
@ -226,7 +228,7 @@ final class ApiController extends Controller
|
|||
return;
|
||||
}
|
||||
|
||||
$ticket = TicketMapper::get((int) ($request->getData('ticket')));
|
||||
$ticket = TicketMapper::get()->where('id', (int) ($request->getData('ticket')))->execute();
|
||||
$element = $this->createTicketElementFromRequest($request, $ticket);
|
||||
$ticket->task->setStatus($element->taskElement->getStatus());
|
||||
$ticket->task->setPriority($element->taskElement->getPriority());
|
||||
|
|
@ -273,7 +275,7 @@ final class ApiController extends Controller
|
|||
*/
|
||||
public function apiTicketElementGet(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
||||
{
|
||||
$ticket = TicketElementMapper::get((int) $request->getData('id'));
|
||||
$ticket = TicketElementMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Ticket element', 'Ticket element successfully returned.', $ticket);
|
||||
}
|
||||
|
||||
|
|
@ -292,7 +294,7 @@ final class ApiController extends Controller
|
|||
*/
|
||||
public function apiTicketElementSet(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
||||
{
|
||||
$old = clone TicketElementMapper::get((int) $request->getData('id'));
|
||||
$old = clone TicketElementMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$new = $this->updateTicketElementFromRequest($request, $response);
|
||||
$this->updateModel($request->header->account, $old, $new, TicketElementMapper::class, 'ticketelement', $request->getOrigin());
|
||||
|
||||
|
|
@ -311,7 +313,8 @@ final class ApiController extends Controller
|
|||
*/
|
||||
private function updateTicketElementFromRequest(RequestAbstract $request, ResponseAbstract $response) : TicketElementMapper
|
||||
{
|
||||
$element = TicketElementMapper::get((int) ($request->getData('id')));
|
||||
/** @var TicketElementMapper $element */
|
||||
$element = TicketElementMapper::get()->where('id', (int) ($request->getData('id')))->execute();
|
||||
|
||||
$request->setData('id', $element->task, true);
|
||||
$this->app->moduleManager->get('Tasks')->apiTaskElementSet($request, $response);
|
||||
|
|
|
|||
|
|
@ -76,23 +76,24 @@ final class BackendController extends Controller
|
|||
$view->setTemplate('/Modules/Support/Theme/Backend/support-list');
|
||||
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1002901101, $request, $response));
|
||||
|
||||
$mapperQuery = TicketMapper::getAll()
|
||||
->with('task')
|
||||
->with('task/createdBy')
|
||||
->with('for')
|
||||
->with('app')
|
||||
->limit(25);
|
||||
|
||||
if ($request->getData('ptype') === 'p') {
|
||||
$view->setData('tickets',
|
||||
TicketMapper::with('language', $response->getLanguage())
|
||||
::with('ticketElements', models: null)
|
||||
::getBeforePivot((int) ($request->getData('id') ?? 0), limit: 25)
|
||||
$mapperQuery->where('id', (int) ($request->getData('id') ?? 0), '<')->execute()
|
||||
);
|
||||
} elseif ($request->getData('ptype') === 'n') {
|
||||
$view->setData('tickets',
|
||||
TicketMapper::with('language', $response->getLanguage())
|
||||
::with('ticketElements', models: null)
|
||||
::getAfterPivot((int) ($request->getData('id') ?? 0), limit: 25)
|
||||
$mapperQuery->where('id', (int) ($request->getData('id') ?? 0), '>')->execute()
|
||||
);
|
||||
} else {
|
||||
$view->setData('tickets',
|
||||
TicketMapper::with('language', $response->getLanguage())
|
||||
::with('ticketElements', models: null)
|
||||
::getAfterPivot(0, limit: 25)
|
||||
$mapperQuery->where('id', 0, '>')->execute()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -118,9 +119,18 @@ final class BackendController extends Controller
|
|||
$view->setTemplate('/Modules/Support/Theme/Backend/support-ticket');
|
||||
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1002901101, $request, $response));
|
||||
|
||||
$mapperQuery = TicketMapper::get()
|
||||
->with('task')
|
||||
->with('task/createdBy')
|
||||
->with('ticketElements')
|
||||
->with('ticketElements/taskElement')
|
||||
->with('attributes')
|
||||
->with('for')
|
||||
->with('app');
|
||||
|
||||
$ticket = $request->getData('for') !== null
|
||||
? TicketMapper::getFor((int) $request->getData('for'), 'task')
|
||||
: TicketMapper::get((int) $request->getData('id'));
|
||||
? $mapperQuery->where('task', (int) $request->getData('for'))->execute()
|
||||
: $mapperQuery->where('id', (int) $request->getData('id'))->execute();
|
||||
|
||||
$view->addData('ticket', $ticket);
|
||||
|
||||
|
|
@ -235,12 +245,12 @@ final class BackendController extends Controller
|
|||
|
||||
$id = $request->getData('id') ?? '';
|
||||
|
||||
$settings = SettingMapper::getFor($id, 'module');
|
||||
$settings = SettingMapper::getAll()->where('module', $id)->execute();
|
||||
if (!($settings instanceof NullSetting)) {
|
||||
$view->setData('settings', !\is_array($settings) ? [$settings] : $settings);
|
||||
}
|
||||
|
||||
$applications = SupportAppMapper::getAll();
|
||||
$applications = SupportAppMapper::getAll()->execute();
|
||||
$view->setData('applications', $applications);
|
||||
|
||||
if (\is_file(__DIR__ . '/../Admin/Settings/Theme/Backend/settings.tpl.php')) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Mapper class.
|
||||
|
|
@ -24,7 +24,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
|
|||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class SupportAppMapper extends DataMapperAbstract
|
||||
final class SupportAppMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
|
|
@ -32,7 +32,7 @@ final class SupportAppMapper extends DataMapperAbstract
|
|||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $columns = [
|
||||
public const COLUMNS = [
|
||||
'support_app_id' => ['name' => 'support_app_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'support_app_name' => ['name' => 'support_app_name', 'type' => 'string', 'internal' => 'name'],
|
||||
];
|
||||
|
|
@ -43,7 +43,7 @@ final class SupportAppMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'support_app';
|
||||
public const TABLE = 'support_app';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
|
|
@ -51,5 +51,5 @@ final class SupportAppMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'support_app_id';
|
||||
public const PRIMARYFIELD ='support_app_id';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Ticket mapper class.
|
||||
|
|
@ -24,7 +24,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
|
|||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class TicketAttributeMapper extends DataMapperAbstract
|
||||
final class TicketAttributeMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
|
|
@ -32,7 +32,7 @@ final class TicketAttributeMapper extends DataMapperAbstract
|
|||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $columns = [
|
||||
public const COLUMNS = [
|
||||
'support_ticket_attr_id' => ['name' => 'support_ticket_attr_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'support_ticket_attr_ticket' => ['name' => 'support_ticket_attr_ticket', 'type' => 'int', 'internal' => 'ticket'],
|
||||
'support_ticket_attr_type' => ['name' => 'support_ticket_attr_type', 'type' => 'int', 'internal' => 'type'],
|
||||
|
|
@ -45,7 +45,7 @@ final class TicketAttributeMapper extends DataMapperAbstract
|
|||
* @var array<string, array{mapper:string, external:string, by?:string, column?:string, conditional?:bool}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $ownsOne = [
|
||||
public const OWNS_ONE = [
|
||||
'type' => [
|
||||
'mapper' => TicketAttributeTypeMapper::class,
|
||||
'external' => 'support_ticket_attr_type',
|
||||
|
|
@ -62,7 +62,7 @@ final class TicketAttributeMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'support_ticket_attr';
|
||||
public const TABLE = 'support_ticket_attr';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
|
|
@ -70,5 +70,5 @@ final class TicketAttributeMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'support_ticket_attr_id';
|
||||
public const PRIMARYFIELD ='support_ticket_attr_id';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Ticket mapper class.
|
||||
|
|
@ -24,7 +24,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
|
|||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class TicketAttributeTypeL11nMapper extends DataMapperAbstract
|
||||
final class TicketAttributeTypeL11nMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
|
|
@ -32,7 +32,7 @@ final class TicketAttributeTypeL11nMapper extends DataMapperAbstract
|
|||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $columns = [
|
||||
public const COLUMNS = [
|
||||
'support_attr_type_l11n_id' => ['name' => 'support_attr_type_l11n_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'support_attr_type_l11n_title' => ['name' => 'support_attr_type_l11n_title', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true],
|
||||
'support_attr_type_l11n_type' => ['name' => 'support_attr_type_l11n_type', 'type' => 'int', 'internal' => 'type'],
|
||||
|
|
@ -45,7 +45,7 @@ final class TicketAttributeTypeL11nMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'support_attr_type_l11n';
|
||||
public const TABLE = 'support_attr_type_l11n';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
|
|
@ -53,5 +53,5 @@ final class TicketAttributeTypeL11nMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'support_attr_type_l11n_id';
|
||||
public const PRIMARYFIELD ='support_attr_type_l11n_id';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Ticket mapper class.
|
||||
|
|
@ -24,7 +24,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
|
|||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class TicketAttributeTypeMapper extends DataMapperAbstract
|
||||
final class TicketAttributeTypeMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
|
|
@ -32,7 +32,7 @@ final class TicketAttributeTypeMapper extends DataMapperAbstract
|
|||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $columns = [
|
||||
public const COLUMNS = [
|
||||
'support_attr_type_id' => ['name' => 'support_attr_type_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'support_attr_type_name' => ['name' => 'support_attr_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
|
||||
'support_attr_type_fields' => ['name' => 'support_attr_type_fields', 'type' => 'int', 'internal' => 'fields'],
|
||||
|
|
@ -47,21 +47,19 @@ final class TicketAttributeTypeMapper extends DataMapperAbstract
|
|||
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $hasMany = [
|
||||
public const HAS_MANY = [
|
||||
'l11n' => [
|
||||
'mapper' => TicketAttributeTypeL11nMapper::class,
|
||||
'table' => 'support_attr_type_l11n',
|
||||
'self' => 'support_attr_type_l11n_type',
|
||||
'column' => 'title',
|
||||
'conditional' => true,
|
||||
'external' => null,
|
||||
],
|
||||
'defaults' => [
|
||||
'mapper' => TicketAttributeValueMapper::class,
|
||||
'table' => 'support_ticket_attr_default',
|
||||
'self' => 'support_ticket_attr_default_type',
|
||||
'external' => 'support_ticket_attr_default_value',
|
||||
'conditional' => false,
|
||||
'external' => 'support_ticket_attr_default_value'
|
||||
],
|
||||
];
|
||||
|
||||
|
|
@ -71,7 +69,7 @@ final class TicketAttributeTypeMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'support_attr_type';
|
||||
public const TABLE = 'support_attr_type';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
|
|
@ -79,5 +77,5 @@ final class TicketAttributeTypeMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'support_attr_type_id';
|
||||
public const PRIMARYFIELD ='support_attr_type_id';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Support\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Ticket mapper class.
|
||||
|
|
@ -24,7 +24,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
|
|||
* @link https: //orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class TicketAttributeValueMapper extends DataMapperAbstract
|
||||
final class TicketAttributeValueMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
|
|
@ -32,7 +32,7 @@ final class TicketAttributeValueMapper extends DataMapperAbstract
|
|||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $columns = [
|
||||
public const COLUMNS = [
|
||||
'support_attr_value_id' => ['name' => 'support_attr_value_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'support_attr_value_default' => ['name' => 'support_attr_value_default', 'type' => 'bool', 'internal' => 'isDefault'],
|
||||
'support_attr_value_type' => ['name' => 'support_attr_value_type', 'type' => 'int', 'internal' => 'type'],
|
||||
|
|
@ -50,7 +50,7 @@ final class TicketAttributeValueMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'support_attr_value';
|
||||
public const TABLE = 'support_attr_value';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
|
|
@ -58,5 +58,5 @@ final class TicketAttributeValueMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'support_attr_value_id';
|
||||
public const PRIMARYFIELD ='support_attr_value_id';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ declare(strict_types=1);
|
|||
namespace Modules\Support\Models;
|
||||
|
||||
use Modules\Tasks\Models\TaskElementMapper;
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Mapper class.
|
||||
|
|
@ -25,7 +25,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
|
|||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class TicketElementMapper extends DataMapperAbstract
|
||||
final class TicketElementMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
|
|
@ -33,7 +33,7 @@ final class TicketElementMapper extends DataMapperAbstract
|
|||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $columns = [
|
||||
public const COLUMNS = [
|
||||
'support_ticket_element_id' => ['name' => 'support_ticket_element_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'support_ticket_element_task_element' => ['name' => 'support_ticket_element_task_element', 'type' => 'int', 'internal' => 'taskElement'],
|
||||
'support_ticket_element_time' => ['name' => 'support_ticket_element_time', 'type' => 'int', 'internal' => 'time'],
|
||||
|
|
@ -46,7 +46,7 @@ final class TicketElementMapper extends DataMapperAbstract
|
|||
* @var array<string, array{mapper:string, external:string, by?:string, column?:string, conditional?:bool}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $ownsOne = [
|
||||
public const OWNS_ONE = [
|
||||
'taskElement' => [
|
||||
'mapper' => TaskElementMapper::class,
|
||||
'external' => 'support_ticket_element_task_element',
|
||||
|
|
@ -59,7 +59,7 @@ final class TicketElementMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'support_ticket_element';
|
||||
public const TABLE = 'support_ticket_element';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
|
|
@ -67,5 +67,5 @@ final class TicketElementMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'support_ticket_element_id';
|
||||
public const PRIMARYFIELD ='support_ticket_element_id';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace Modules\Support\Models;
|
|||
|
||||
use Modules\Admin\Models\AccountMapper;
|
||||
use Modules\Tasks\Models\TaskMapper;
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Mapper class.
|
||||
|
|
@ -26,7 +26,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
|
|||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class TicketMapper extends DataMapperAbstract
|
||||
final class TicketMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
|
|
@ -34,7 +34,7 @@ final class TicketMapper extends DataMapperAbstract
|
|||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $columns = [
|
||||
public const COLUMNS = [
|
||||
'support_ticket_id' => ['name' => 'support_ticket_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'support_ticket_task' => ['name' => 'support_ticket_task', 'type' => 'int', 'internal' => 'task'],
|
||||
'support_ticket_for' => ['name' => 'support_ticket_for', 'type' => 'int', 'internal' => 'for'],
|
||||
|
|
@ -47,7 +47,7 @@ final class TicketMapper extends DataMapperAbstract
|
|||
* @var array<string, array{mapper:string, external:string, by?:string, column?:string, conditional?:bool}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $ownsOne = [
|
||||
public const OWNS_ONE = [
|
||||
'task' => [
|
||||
'mapper' => TaskMapper::class,
|
||||
'external' => 'support_ticket_task',
|
||||
|
|
@ -60,7 +60,7 @@ final class TicketMapper extends DataMapperAbstract
|
|||
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $hasMany = [
|
||||
public const HAS_MANY = [
|
||||
'ticketElements' => [
|
||||
'mapper' => TicketElementMapper::class,
|
||||
'table' => 'support_ticket_element',
|
||||
|
|
@ -82,7 +82,7 @@ final class TicketMapper extends DataMapperAbstract
|
|||
* @var array<string, array{mapper:string, external:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $belongsTo = [
|
||||
public const BELONGS_TO = [
|
||||
'app' => [
|
||||
'mapper' => SupportAppMapper::class,
|
||||
'external' => 'support_ticket_app',
|
||||
|
|
@ -99,7 +99,7 @@ final class TicketMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'support_ticket';
|
||||
public const TABLE = 'support_ticket';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
|
|
@ -107,5 +107,5 @@ final class TicketMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'support_ticket_id';
|
||||
public const PRIMARYFIELD ='support_ticket_id';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ use phpOMS\Uri\UriFactory;
|
|||
$ticket = $this->getData('ticket');
|
||||
$task = $ticket->task;
|
||||
$taskMedia = $task->getMedia();
|
||||
$elements = $task->invertTaskElements();
|
||||
$elements = $ticket->invertTicketElements();
|
||||
$cElements = \count($elements);
|
||||
$color = 'red'; //$this->getStatus($task->getStatus());
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class TicketView extends View
|
|||
*/
|
||||
public function getAccountImage(int $account) : string
|
||||
{
|
||||
$profile = ProfileMapper::getFor($account, 'account');
|
||||
$profile = ProfileMapper::get()->with('image')->where('account', $account)->execute();
|
||||
|
||||
if (($profile instanceof NullProfile) || $profile->image->getPath() === '') {
|
||||
return UriFactory::build('{/prefix}' . $this->defaultProfileImage->getPath());
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ require_once __DIR__ . '/../vendor/autoload.php';
|
|||
require_once __DIR__ . '/Autoloader.php';
|
||||
|
||||
use phpOMS\DataStorage\Database\DatabasePool;
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
use phpOMS\DataStorage\Session\HttpSession;
|
||||
|
||||
$CONFIG = [
|
||||
|
|
@ -329,7 +329,7 @@ $GLOBALS['dbpool']->create('delete', $CONFIG['db']['core']['masters']['delete'])
|
|||
$GLOBALS['dbpool']->create('insert', $CONFIG['db']['core']['masters']['insert']);
|
||||
$GLOBALS['dbpool']->create('schema', $CONFIG['db']['core']['masters']['schema']);
|
||||
|
||||
DataMapperAbstract::setConnection($GLOBALS['dbpool']->get());
|
||||
DataMapperFactory::db($GLOBALS['dbpool']->get());
|
||||
|
||||
$GLOBALS['frameworkpath'] = '/phpOMS/';
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user