mirror of
https://github.com/Karaka-Management/oms-Calendar.git
synced 2026-02-02 01:38:42 +00:00
Making datamapper static
This commit is contained in:
parent
5e8352a41d
commit
bbad0a7c41
|
|
@ -87,7 +87,7 @@ class Controller extends ModuleAbstract implements WebInterface
|
|||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return RenderableInterface
|
||||
* @return \Serializable
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
|
|
@ -98,8 +98,7 @@ class Controller extends ModuleAbstract implements WebInterface
|
|||
$view->setTemplate('/Modules/Calendar/Theme/Backend/calendar-dashboard');
|
||||
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1001201001, $request, $response));
|
||||
|
||||
$mapper = new CalendarMapper($this->app->dbPool->get());
|
||||
$calendar = $mapper->get(1);
|
||||
$calendar = CalendarMapper::get(1);
|
||||
$calendar->setDate(new SmartDateTime($request->getData('date') ?? 'now'));
|
||||
$view->addData('calendar', $calendar);
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,13 @@ use phpOMS\DataStorage\Database\Query\Column;
|
|||
*/
|
||||
class CalendarMapper extends DataMapperAbstract
|
||||
{
|
||||
/**
|
||||
* Class name for .
|
||||
*
|
||||
* @var array<string, array>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static $CLASS = __CLASS__;
|
||||
|
||||
/**
|
||||
* Columns.
|
||||
|
|
@ -98,12 +105,12 @@ class CalendarMapper extends DataMapperAbstract
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function create($obj)
|
||||
public static function create($obj, bool $relations = true)
|
||||
{
|
||||
try {
|
||||
$objId = parent::create($obj);
|
||||
$query = new Builder($this->db);
|
||||
$query->prefix($this->db->getPrefix())
|
||||
$objId = parent::create($obj, $relations);
|
||||
$query = new Builder(self::$db);
|
||||
$query->prefix(self::$db->getPrefix())
|
||||
->insert(
|
||||
'account_permission_account',
|
||||
'account_permission_from',
|
||||
|
|
@ -119,7 +126,7 @@ class CalendarMapper extends DataMapperAbstract
|
|||
->into('account_permission')
|
||||
->values($obj->getCreatedBy(), 'calendar', 'calendar', 1, $objId, 1, 1, 1, 1, 1);
|
||||
|
||||
$this->db->con->prepare($query->toSql())->execute();
|
||||
self::$db->con->prepare($query->toSql())->execute();
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -137,7 +144,7 @@ class CalendarMapper extends DataMapperAbstract
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function find(...$columns) : Builder
|
||||
public static function find(...$columns) : Builder
|
||||
{
|
||||
return parent::find(...$columns)->from('account_permission')
|
||||
->where('account_permission.account_permission_for', '=', 'calendar')
|
||||
|
|
|
|||
|
|
@ -99,13 +99,13 @@ class EventMapper extends DataMapperAbstract
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function create($obj)
|
||||
public static function create($obj, bool $relations = true)
|
||||
{
|
||||
try {
|
||||
$objId = parent::create($obj);
|
||||
$query = new Builder($this->db);
|
||||
$objId = parent::create($obj, $relations);
|
||||
$query = new Builder(self::$db);
|
||||
|
||||
$query->prefix($this->db->getPrefix())
|
||||
$query->prefix(self::$db->getPrefix())
|
||||
->insert(
|
||||
'account_permission_account',
|
||||
'account_permission_from',
|
||||
|
|
@ -121,7 +121,7 @@ class EventMapper extends DataMapperAbstract
|
|||
->into('account_permission')
|
||||
->values($obj->getCreatedBy(), 'calendar_event', 'calendar_event', 1, $objId, 1, 1, 1, 1, 1);
|
||||
|
||||
$this->db->con->prepare($query->toSql())->execute();
|
||||
self::$db->con->prepare($query->toSql())->execute();
|
||||
} catch (\Exception $e) {
|
||||
var_dump($e->getMessage());
|
||||
|
||||
|
|
@ -141,7 +141,7 @@ class EventMapper extends DataMapperAbstract
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function find(...$columns) : Builder
|
||||
public static function find(...$columns) : Builder
|
||||
{
|
||||
return parent::find(...$columns)->from('account_permission')
|
||||
->where('account_permission.account_permission_for', '=', 'calendar_event')
|
||||
|
|
|
|||
|
|
@ -89,12 +89,12 @@ class ScheduleMapper extends DataMapperAbstract
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function create($obj)
|
||||
public static function create($obj, bool $relations = true)
|
||||
{
|
||||
try {
|
||||
$objId = parent::create($obj);
|
||||
$query = new Builder($this->db);
|
||||
$query->prefix($this->db->getPrefix())
|
||||
$objId = parent::create($obj, $relations);
|
||||
$query = new Builder(self::$db);
|
||||
$query->prefix(self::$db->getPrefix())
|
||||
->insert(
|
||||
'account_permission_account',
|
||||
'account_permission_from',
|
||||
|
|
@ -110,7 +110,7 @@ class ScheduleMapper extends DataMapperAbstract
|
|||
->into('account_permission')
|
||||
->values($obj->getCreatedBy(), 'schedule', 'schedule', 1, $objId, 1, 1, 1, 1, 1);
|
||||
|
||||
$this->db->con->prepare($query->toSql())->execute();
|
||||
self::$db->con->prepare($query->toSql())->execute();
|
||||
} catch (\Exception $e) {
|
||||
var_dump($e->getMessage());
|
||||
|
||||
|
|
@ -130,7 +130,7 @@ class ScheduleMapper extends DataMapperAbstract
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function find(...$columns) : Builder
|
||||
public static function find(...$columns) : Builder
|
||||
{
|
||||
return parent::find(...$columns)->from('account_permission')
|
||||
->where('account_permission.account_permission_for', '=', 'calendar')
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user