Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

namespace VuFind\Db\Entity;

use DateTime;

/**
* Entity model interface for external_session table
*
Expand All @@ -40,4 +42,58 @@
*/
interface ExternalSessionEntityInterface extends EntityInterface
{
/**
* Get identifier (returns null for an uninitialized or non-persisted object).
*
* @return ?int
*/
public function getId(): ?int;

/**
* Get PHP session id string.
*
* @return string
*/
public function getSessionId(): string;

/**
* Set PHP session id string.
*
* @param string $sessionId PHP Session id string
*
* @return ExternalSessionEntityInterface
*/
public function setSessionId(string $sessionId): ExternalSessionEntityInterface;

/**
* Get external session id string.
*
* @return string
*/
public function getExternalSessionId(): string;

/**
* Set external session id string.
*
* @param string $externalSessionId external session id string
*
* @return ExternalSessionEntityInterface
*/
public function setExternalSessionId(string $externalSessionId): ExternalSessionEntityInterface;

/**
* Get created date.
*
* @return DateTime
*/
public function getCreated(): DateTime;

/**
* Set created date.
*
* @param DateTime $dateTime Created date
*
* @return ExternalSessionEntityInterface
*/
public function setCreated(DateTime $dateTime): ExternalSessionEntityInterface;
}
87 changes: 87 additions & 0 deletions module/VuFind/src/VuFind/Db/Row/ExternalSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@

namespace VuFind\Db\Row;

use DateTime;
use VuFind\Db\Entity\ExternalSessionEntityInterface;

/**
* Row Definition for external_session
*
Expand All @@ -40,6 +43,11 @@
* @author Ere Maijala <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org Main Site
*
* @property int $id
* @property string $session_id
* @property string $external_session_id
* @property string $created
*/
class ExternalSession extends RowGateway implements \VuFind\Db\Entity\ExternalSessionEntityInterface
{
Expand All @@ -52,4 +60,83 @@ public function __construct($adapter)
{
parent::__construct('id', 'external_session', $adapter);
}

/**
* Get identifier (returns null for an uninitialized or non-persisted object).
*
* @return ?int
*/
public function getId(): ?int
{
return $this->id ?? null;
}

/**
* Get PHP session id string.
*
* @return string
*/
public function getSessionId(): string
{
return $this->session_id ?? '';
}

/**
* Set PHP session id string.
*
* @param string $sessionId PHP Session id string
*
* @return ExternalSessionEntityInterface
*/
public function setSessionId(string $sessionId): ExternalSessionEntityInterface
{
$this->session_id = $sessionId;
return $this;
}

/**
* Get PHP external session id string.
*
* @return string
*/
public function getExternalSessionId(): string
{
return $this->external_session_id ?? '';
}

/**
* Set external session id string.
*
* @param string $externalSessionId external session id string
*
* @return ExternalSessionEntityInterface
*/
public function setExternalSessionId(string $externalSessionId): ExternalSessionEntityInterface
{
$this->external_session_id = $externalSessionId;
return $this;
}

/**
* Get created date.
*
* @return DateTime
*/
public function getCreated(): DateTime
{
return DateTime::createFromFormat('Y-m-d H:i:s', $this->created);
}

/**
* Set created date.
*
* @param DateTime $dateTime Created date
*
* @return ExternalSessionEntityInterface
*/
public function setCreated(DateTime $dateTime): ExternalSessionEntityInterface
{
$this->created = $dateTime->format('Y-m-d H:i:s');
return $this;
}
}