mirror of
https://github.com/Karaka-Management/oms-ClientManagement.git
synced 2026-04-27 02:38:40 +00:00
new datamapper mostly implemented
This commit is contained in:
parent
9b1cf99422
commit
fa7e92a8b5
|
|
@ -20,6 +20,7 @@ use Modules\ClientManagement\Models\ClientMapper;
|
|||
use Modules\Media\Models\Media;
|
||||
use phpOMS\Asset\AssetType;
|
||||
use phpOMS\Contract\RenderableInterface;
|
||||
use phpOMS\DataStorage\Database\Query\OrderType;
|
||||
use phpOMS\Localization\ISO3166CharEnum;
|
||||
use phpOMS\Localization\ISO3166NameEnum;
|
||||
use phpOMS\Localization\Money;
|
||||
|
|
@ -57,10 +58,13 @@ final class BackendController extends Controller
|
|||
$view->setTemplate('/Modules/ClientManagement/Theme/Backend/client-list');
|
||||
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1003102001, $request, $response));
|
||||
|
||||
$client = ClientMapper::with('notes', models: null)
|
||||
::with('contactElements', models: null)
|
||||
//::with('type', 'backend_image', models: [Media::class]) // @todo: it would be nicer if I coult say files:type or files/type and remove the models parameter? @todo: uncommented for now because the type is also part of client and therefore bug. that's the problem with a mix of black/whitelisting in the datamapper with the "with" feature. make it whitelist only for belongsTo, ownsMany, hasOne, ....
|
||||
::getAfterPivot(0, null, 25);
|
||||
$client = ClientMapper::getAll()
|
||||
->with('profile')
|
||||
->with('profile/account')
|
||||
->with('profile/image')
|
||||
->with('mainAddress')
|
||||
->limit(25)
|
||||
->execute();
|
||||
|
||||
$view->addData('client', $client);
|
||||
|
||||
|
|
@ -111,10 +115,15 @@ final class BackendController extends Controller
|
|||
$view->setTemplate('/Modules/ClientManagement/Theme/Backend/client-profile');
|
||||
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1003102001, $request, $response));
|
||||
|
||||
$client = ClientMapper
|
||||
::with('files', limit: 5)::orderBy('createdAt', 'ASC')
|
||||
::with('notes', limit: 5)::orderBy('id', 'ASC')
|
||||
::get((int) $request->getData('id'));
|
||||
$client = ClientMapper::get()
|
||||
->with('profile')
|
||||
->with('profile/account')
|
||||
->with('contactElements')
|
||||
->with('mainAddress')
|
||||
->with('files')->limit(5, 'files')->sort('files', OrderType::DESC)
|
||||
->with('notes')->limit(5, 'files')->sort('notes', OrderType::DESC)
|
||||
->where('id', (int) $request->getData('id'))
|
||||
->execute();
|
||||
|
||||
$view->setData('client', $client);
|
||||
|
||||
|
|
@ -123,9 +132,7 @@ final class BackendController extends Controller
|
|||
$ytd = SalesBillMapper::getSalesByClientId($client->getId(), new SmartDateTime('Y-01-01'), new SmartDateTime('now'));
|
||||
$mtd = SalesBillMapper::getSalesByClientId($client->getId(), new SmartDateTime('Y-m-01'), new SmartDateTime('now'));
|
||||
$lastOrder = SalesBillMapper::getLastOrderDateByClientId($client->getId());
|
||||
$newestInvoices = SalesBillMapper
|
||||
::with('language', $response->getLanguage(), [BillTypeL11n::class])
|
||||
::getNewestClientInvoices($client->getId(), 5);
|
||||
$newestInvoices = SalesBillMapper::getAll()->with('client')->where('client', $client->getId())->sort('id', OrderType::DESC)->limit(5)->execute();
|
||||
$monthlySalesCosts = SalesBillMapper::getClientMonthlySalesCosts($client->getId(), (new SmartDateTime('now'))->createModify(-1), new SmartDateTime('now'));
|
||||
$items = SalesBillMapper::getClientItem($client->getId(), (new SmartDateTime('now'))->createModify(-1), new SmartDateTime('now'));
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use Modules\Admin\Models\Address;
|
|||
use Modules\Admin\Models\NullAddress;
|
||||
use Modules\Editor\Models\EditorDoc;
|
||||
use Modules\Media\Models\Media;
|
||||
use Modules\Media\Models\NullMedia;
|
||||
use Modules\Profile\Models\ContactElement;
|
||||
use Modules\Profile\Models\NullContactElement;
|
||||
use Modules\Profile\Models\Profile;
|
||||
|
|
@ -308,6 +309,26 @@ class Client
|
|||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all media files by type
|
||||
*
|
||||
* @param int $type Media type
|
||||
*
|
||||
* @return Media
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getFileByType(int $type) : Media
|
||||
{
|
||||
foreach ($this->files as $file) {
|
||||
if ($file->type === $type) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
return new NullMedia();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\ClientManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Client mapper class.
|
||||
|
|
@ -24,7 +24,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
|
|||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class ClientAttributeMapper extends DataMapperAbstract
|
||||
final class ClientAttributeMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
|
|
@ -32,7 +32,7 @@ final class ClientAttributeMapper 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 = [
|
||||
'clientmgmt_client_attr_id' => ['name' => 'clientmgmt_client_attr_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'clientmgmt_client_attr_client' => ['name' => 'clientmgmt_client_attr_client', 'type' => 'int', 'internal' => 'client'],
|
||||
'clientmgmt_client_attr_type' => ['name' => 'clientmgmt_client_attr_type', 'type' => 'int', 'internal' => 'type'],
|
||||
|
|
@ -45,7 +45,7 @@ final class ClientAttributeMapper 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' => ClientAttributeTypeMapper::class,
|
||||
'external' => 'clientmgmt_client_attr_type',
|
||||
|
|
@ -62,7 +62,7 @@ final class ClientAttributeMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'clientmgmt_client_attr';
|
||||
public const TABLE = 'clientmgmt_client_attr';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
|
|
@ -70,5 +70,5 @@ final class ClientAttributeMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'clientmgmt_client_attr_id';
|
||||
public const PRIMARYFIELD ='clientmgmt_client_attr_id';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\ClientManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Client mapper class.
|
||||
|
|
@ -24,7 +24,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
|
|||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class ClientAttributeTypeL11nMapper extends DataMapperAbstract
|
||||
final class ClientAttributeTypeL11nMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
|
|
@ -32,7 +32,7 @@ final class ClientAttributeTypeL11nMapper 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 = [
|
||||
'clientmgmt_attr_type_l11n_id' => ['name' => 'clientmgmt_attr_type_l11n_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'clientmgmt_attr_type_l11n_title' => ['name' => 'clientmgmt_attr_type_l11n_title', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true],
|
||||
'clientmgmt_attr_type_l11n_type' => ['name' => 'clientmgmt_attr_type_l11n_type', 'type' => 'int', 'internal' => 'type'],
|
||||
|
|
@ -45,7 +45,7 @@ final class ClientAttributeTypeL11nMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'clientmgmt_attr_type_l11n';
|
||||
public const TABLE = 'clientmgmt_attr_type_l11n';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
|
|
@ -53,5 +53,5 @@ final class ClientAttributeTypeL11nMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'clientmgmt_attr_type_l11n_id';
|
||||
public const PRIMARYFIELD ='clientmgmt_attr_type_l11n_id';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\ClientManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Client mapper class.
|
||||
|
|
@ -24,7 +24,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
|
|||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class ClientAttributeTypeMapper extends DataMapperAbstract
|
||||
final class ClientAttributeTypeMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
|
|
@ -32,7 +32,7 @@ final class ClientAttributeTypeMapper 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 = [
|
||||
'clientmgmt_attr_type_id' => ['name' => 'clientmgmt_attr_type_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'clientmgmt_attr_type_name' => ['name' => 'clientmgmt_attr_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
|
||||
'clientmgmt_attr_type_fields' => ['name' => 'clientmgmt_attr_type_fields', 'type' => 'int', 'internal' => 'fields'],
|
||||
|
|
@ -47,21 +47,19 @@ final class ClientAttributeTypeMapper 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' => ClientAttributeTypeL11nMapper::class,
|
||||
'table' => 'clientmgmt_attr_type_l11n',
|
||||
'self' => 'clientmgmt_attr_type_l11n_type',
|
||||
'column' => 'title',
|
||||
'conditional' => true,
|
||||
'external' => null,
|
||||
],
|
||||
'defaults' => [
|
||||
'mapper' => ClientAttributeValueMapper::class,
|
||||
'table' => 'clientmgmt_client_attr_default',
|
||||
'self' => 'clientmgmt_client_attr_default_type',
|
||||
'external' => 'clientmgmt_client_attr_default_value',
|
||||
'conditional' => false,
|
||||
'external' => 'clientmgmt_client_attr_default_value'
|
||||
],
|
||||
];
|
||||
|
||||
|
|
@ -71,7 +69,7 @@ final class ClientAttributeTypeMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'clientmgmt_attr_type';
|
||||
public const TABLE = 'clientmgmt_attr_type';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
|
|
@ -79,5 +77,5 @@ final class ClientAttributeTypeMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'clientmgmt_attr_type_id';
|
||||
public const PRIMARYFIELD ='clientmgmt_attr_type_id';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\ClientManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Client mapper class.
|
||||
|
|
@ -24,7 +24,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
|
|||
* @link https: //orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class ClientAttributeValueMapper extends DataMapperAbstract
|
||||
final class ClientAttributeValueMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
|
|
@ -32,7 +32,7 @@ final class ClientAttributeValueMapper 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 = [
|
||||
'clientmgmt_attr_value_id' => ['name' => 'clientmgmt_attr_value_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'clientmgmt_attr_value_default' => ['name' => 'clientmgmt_attr_value_default', 'type' => 'bool', 'internal' => 'isDefault'],
|
||||
'clientmgmt_attr_value_type' => ['name' => 'clientmgmt_attr_value_type', 'type' => 'int', 'internal' => 'type'],
|
||||
|
|
@ -50,7 +50,7 @@ final class ClientAttributeValueMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'clientmgmt_attr_value';
|
||||
public const TABLE = 'clientmgmt_attr_value';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
|
|
@ -58,5 +58,5 @@ final class ClientAttributeValueMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'clientmgmt_attr_value_id';
|
||||
public const PRIMARYFIELD ='clientmgmt_attr_value_id';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use Modules\Editor\Models\EditorDocMapper;
|
|||
use Modules\Media\Models\MediaMapper;
|
||||
use Modules\Profile\Models\ContactElementMapper;
|
||||
use Modules\Profile\Models\ProfileMapper;
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Client mapper class.
|
||||
|
|
@ -29,7 +29,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
|
|||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class ClientMapper extends DataMapperAbstract
|
||||
final class ClientMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
|
|
@ -37,7 +37,7 @@ final class ClientMapper 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 = [
|
||||
'clientmgmt_client_id' => ['name' => 'clientmgmt_client_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'clientmgmt_client_no' => ['name' => 'clientmgmt_client_no', 'type' => 'string', 'internal' => 'number'],
|
||||
'clientmgmt_client_no_reverse' => ['name' => 'clientmgmt_client_no_reverse', 'type' => 'string', 'internal' => 'numberReverse'],
|
||||
|
|
@ -55,7 +55,7 @@ final class ClientMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'clientmgmt_client';
|
||||
public const TABLE = 'clientmgmt_client';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
|
|
@ -63,7 +63,7 @@ final class ClientMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'clientmgmt_client_id';
|
||||
public const PRIMARYFIELD ='clientmgmt_client_id';
|
||||
|
||||
/**
|
||||
* Created at column
|
||||
|
|
@ -71,7 +71,7 @@ final class ClientMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $createdAt = 'clientmgmt_client_created_at';
|
||||
public const CREATED_AT = 'clientmgmt_client_created_at';
|
||||
|
||||
/**
|
||||
* Has one relation.
|
||||
|
|
@ -79,7 +79,7 @@ final class ClientMapper 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 = [
|
||||
'profile' => [
|
||||
'mapper' => ProfileMapper::class,
|
||||
'external' => 'clientmgmt_client_profile',
|
||||
|
|
@ -96,7 +96,7 @@ final class ClientMapper 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 = [
|
||||
'files' => [
|
||||
'mapper' => MediaMapper::class, /* mapper of the related object */
|
||||
'table' => 'clientmgmt_client_media', /* table of the related object, null if no relation table is used (many->1) */
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
<tbody>
|
||||
<?php $count = 0; foreach ($clients as $key => $value) : ++$count;
|
||||
$url = UriFactory::build('{/prefix}sales/client/profile?{?}&id=' . $value->getId());
|
||||
$image = $value->getFileByType('backend_image');
|
||||
$image = $value->getFileByType(0);
|
||||
?>
|
||||
<tr data-href="<?= $url; ?>">
|
||||
<td><a href="<?= $url; ?>"><img width="30" loading="lazy" class="item-image"
|
||||
|
|
|
|||
|
|
@ -162,7 +162,9 @@ $bills = $this->getData('newestInvoices') ?? [];
|
|||
<i class="filter fa fa-filter"></i>
|
||||
</label>
|
||||
<tbody>
|
||||
<?php $count = 0; foreach ($bills as $key => $value) :
|
||||
<?php $count = 0;
|
||||
/** @var \Modules\Billing\Models\Bill $value */
|
||||
foreach ($bills as $key => $value) :
|
||||
++$count;
|
||||
$url = UriFactory::build('{/prefix}sales/bill?{?}&id=' . $value->getId());
|
||||
?>
|
||||
|
|
@ -179,8 +181,8 @@ $bills = $this->getData('newestInvoices') ?? [];
|
|||
<td><a href="<?= $url; ?>"><?= $value->billZip; ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->billCity; ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->billCountry; ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->net->getCurrency(); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->profit->getCurrency(); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->netSales->getCurrency(); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->netProfit->getCurrency(); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->createdAt->format('Y-m-d'); ?></a>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($count === 0) : ?>
|
||||
|
|
|
|||
|
|
@ -262,14 +262,16 @@ echo $this->getData('nav')->render();
|
|||
<td><?= $this->getHtml('Net'); ?>
|
||||
<td><?= $this->getHtml('Date'); ?>
|
||||
<tbody>
|
||||
<?php foreach ($newestInvoices as $invoice) :
|
||||
<?php
|
||||
/** @var \Modules\Billing\Models\Bill $invoice */
|
||||
foreach ($newestInvoices as $invoice) :
|
||||
$url = UriFactory::build('{/prefix}sales/bill?{?}&id=' . $invoice->getId());
|
||||
?>
|
||||
<tr data-href="<?= $url; ?>">
|
||||
<td><a href="<?= $url; ?>"><?= $invoice->getNumber(); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $invoice->type->getL11n(); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $invoice->billTo; ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $invoice->net->getCurrency(); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $invoice->netSales->getCurrency(); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $invoice->createdAt->format('Y-m-d'); ?></a>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -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/';
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ final class ClientMapperTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
// This is required because by default a NullAccount without an ID is created in the Profile model
|
||||
// but NullModels without ids are handled like "null" values which are not allowed for Accounts.
|
||||
$profile = ProfileMapper::getFor(1, 'account');
|
||||
$profile = ProfileMapper::get()->where('account', 1)->execute();
|
||||
$profile = $profile instanceof NullProfile ? new Profile() : $profile;
|
||||
if ($profile->account->getId() === 0) {
|
||||
$profile->account = new NullAccount(1);
|
||||
|
|
@ -45,7 +45,7 @@ final class ClientMapperTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
$client->profile = $profile;
|
||||
|
||||
$id = ClientMapper::create($client);
|
||||
$id = ClientMapper::create()->execute($client);
|
||||
self::assertGreaterThan(0, $client->getId());
|
||||
self::assertEquals($id, $client->getId());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user