mirror of
https://github.com/Karaka-Management/oms-Draw.git
synced 2026-01-24 20:08:41 +00:00
new datamapper mostly implemented
This commit is contained in:
parent
82f01fc763
commit
ab017892e1
|
|
@ -17,6 +17,7 @@ namespace Modules\Draw\Controller;
|
|||
use Modules\Draw\Models\DrawImageMapper;
|
||||
use phpOMS\Asset\AssetType;
|
||||
use phpOMS\Contract\RenderableInterface;
|
||||
use phpOMS\DataStorage\Database\Query\OrderType;
|
||||
use phpOMS\Message\RequestAbstract;
|
||||
use phpOMS\Message\ResponseAbstract;
|
||||
use phpOMS\Views\View;
|
||||
|
|
@ -92,7 +93,7 @@ final class BackendController extends Controller
|
|||
$view = new View($this->app->l11nManager, $request, $response);
|
||||
|
||||
/** @var \Modules\Draw\Models\DrawImage $draw */
|
||||
$draw = DrawImageMapper::get((int) ($request->getData('id')));
|
||||
$draw = DrawImageMapper::get()->where('id', (int) ($request->getData('id')))->execute();
|
||||
$accountId = $request->header->account;
|
||||
|
||||
$view->setTemplate('/Modules/Draw/Theme/Backend/draw-single');
|
||||
|
|
@ -123,7 +124,7 @@ final class BackendController extends Controller
|
|||
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005201001, $request, $response));
|
||||
|
||||
/** @var \Modules\Draw\Models\DrawImage[] $images */
|
||||
$images = DrawImageMapper::getNewest(25);
|
||||
$images = DrawImageMapper::getAll()->sort('id', OrderType::DESC)->limit(25);
|
||||
$view->addData('images', $images);
|
||||
|
||||
return $view;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ declare(strict_types=1);
|
|||
namespace Modules\Draw\Models;
|
||||
|
||||
use Modules\Media\Models\MediaMapper;
|
||||
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 DrawImageMapper extends DataMapperAbstract
|
||||
final class DrawImageMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
|
|
@ -33,7 +33,7 @@ final class DrawImageMapper 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 = [
|
||||
'draw_image_id' => ['name' => 'draw_image_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'draw_image_media' => ['name' => 'draw_image_media', 'type' => 'int', 'internal' => 'media'],
|
||||
];
|
||||
|
|
@ -44,7 +44,7 @@ final class DrawImageMapper 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 = [
|
||||
'media' => [
|
||||
'mapper' => MediaMapper::class,
|
||||
'external' => 'draw_image_media',
|
||||
|
|
@ -57,7 +57,7 @@ final class DrawImageMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'draw_image';
|
||||
public const TABLE = 'draw_image';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
|
|
@ -65,5 +65,5 @@ final class DrawImageMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'draw_image_id';
|
||||
public const PRIMARYFIELD ='draw_image_id';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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