mirror of
https://github.com/Karaka-Management/oms-Calendar.git
synced 2026-01-30 16:28:43 +00:00
Cleanup and function pull out
This commit is contained in:
parent
d8ba3a01f8
commit
7d02549bcc
|
|
@ -115,30 +115,9 @@ class Controller extends ModuleAbstract implements WebInterface
|
|||
{
|
||||
$view = new View($this->app, $request, $response);
|
||||
$view->setTemplate('/Modules/Calendar/Theme/Backend/calendar-dashboard');
|
||||
$view->addData('nav', $this->createNavigation(1001201001, $request, $response));
|
||||
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1001201001, $request, $response));
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $pageId Page/parent Id for navigation
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
*
|
||||
* @return RenderableInterface
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
private function createNavigation(int $pageId, RequestAbstract $request, ResponseAbstract $response)
|
||||
{
|
||||
$nav = Navigation::getInstance($request, $this->app->dbPool);
|
||||
$navView = new NavigationView($this->app, $request, $response);
|
||||
$navView->setTemplate('/Modules/Navigation/Theme/Backend/mid');
|
||||
$navView->setNav($nav->getNav());
|
||||
$navView->setLanguage($request->getL11n()->getLanguage());
|
||||
$navView->setParent($pageId);
|
||||
|
||||
return $navView;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@
|
|||
*/
|
||||
namespace Modules\Calendar\Models;
|
||||
|
||||
use phpOMS\Pattern\Multition;
|
||||
|
||||
/**
|
||||
* Calendar class.
|
||||
*
|
||||
|
|
@ -28,7 +26,7 @@ use phpOMS\Pattern\Multition;
|
|||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Calendar implements Multition
|
||||
class Calendar
|
||||
{
|
||||
|
||||
/**
|
||||
|
|
@ -37,7 +35,7 @@ class Calendar implements Multition
|
|||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $id = null;
|
||||
private $id = 0;
|
||||
|
||||
/**
|
||||
* Name.
|
||||
|
|
@ -56,20 +54,20 @@ class Calendar implements Multition
|
|||
private $description = '';
|
||||
|
||||
/**
|
||||
* Created.
|
||||
* Created at.
|
||||
*
|
||||
* @var \Datetime
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $created = null;
|
||||
private $createdAt = null;
|
||||
|
||||
/**
|
||||
* Creator.
|
||||
* Created by.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $creator = null;
|
||||
private $createdBy = 0;
|
||||
|
||||
/**
|
||||
* Events.
|
||||
|
|
@ -79,125 +77,85 @@ class Calendar implements Multition
|
|||
*/
|
||||
private $events = [];
|
||||
|
||||
private static $instances = [];
|
||||
|
||||
public function __construct($id)
|
||||
public function __construct()
|
||||
{
|
||||
$this->createdAt = new \DateTime('now');
|
||||
}
|
||||
|
||||
public function getInstance($id)
|
||||
{
|
||||
if (!isset(self::$instances[$id])) {
|
||||
self::$instances[$id] = new self($id);
|
||||
}
|
||||
|
||||
return self::$instances[$id];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function init($id)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
}
|
||||
|
||||
public function getId()
|
||||
public function getId() : int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
public function getName() : string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName($name)
|
||||
public function setName(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
public function getDescription() : string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription($desc)
|
||||
public function setDescription(string $desc)
|
||||
{
|
||||
$this->description = $desc;
|
||||
}
|
||||
|
||||
public function getEvents()
|
||||
public function addEvent(Event $event) : int
|
||||
{
|
||||
$this->events[] = $event;
|
||||
|
||||
end($this->events);
|
||||
$key = key($this->events);
|
||||
reset($this->events);
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
public function getEvents() : array
|
||||
{
|
||||
return $this->events;
|
||||
}
|
||||
|
||||
public function removeEvent()
|
||||
public function removeEvent($id) : bool
|
||||
{
|
||||
if (isset($this->events[$id])) {
|
||||
unset($this->events[$id]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getEvent($id)
|
||||
public function getEvent($id) : Event
|
||||
{
|
||||
return $this->events[$id] ?? new NullEvent();
|
||||
}
|
||||
|
||||
public function getCreated()
|
||||
public function getCreatedAt() : \DateTime
|
||||
{
|
||||
return $this->created;
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
public function setCreated($created)
|
||||
public function setCreatedAt(\DateTime $createdAt)
|
||||
{
|
||||
$this->created = $created;
|
||||
$this->createdAt = $createdAt;
|
||||
}
|
||||
|
||||
public function getCreator()
|
||||
public function getCreatedBy() : int
|
||||
{
|
||||
return $this->creator;
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
||||
public function setCreator($creator)
|
||||
{
|
||||
$this->creator = $creator;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function serialize()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function unserialize($data)
|
||||
public function setCreatedBy(int $createdBy)
|
||||
{
|
||||
$this->createdBy = $createdBy;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@
|
|||
*/
|
||||
namespace Modules\Calendar\Models;
|
||||
|
||||
use phpOMS\Pattern\Multition;
|
||||
|
||||
/**
|
||||
* Calendar class.
|
||||
*
|
||||
|
|
@ -28,7 +26,7 @@ use phpOMS\Pattern\Multition;
|
|||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Event implements Multition
|
||||
class Event
|
||||
{
|
||||
|
||||
/**
|
||||
|
|
@ -119,21 +117,10 @@ class Event implements Multition
|
|||
*/
|
||||
private $occurence = null;
|
||||
|
||||
private static $instances = [];
|
||||
|
||||
public function __construct($id)
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function getInstance($id)
|
||||
{
|
||||
if (!isset(self::$instances[$id])) {
|
||||
self::$instances[$id] = new self($id);
|
||||
}
|
||||
|
||||
return self::$instances[$id];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
32
Models/NullEvent.php
Normal file
32
Models/NullEvent.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.0
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright 2013 Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace Modules\Calendar\Models;
|
||||
|
||||
/**
|
||||
* Calendar class.
|
||||
*
|
||||
* @category Calendar
|
||||
* @package Framework
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @license OMS License 1.0
|
||||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class NullEvent extends Event
|
||||
{
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user