Added draft for history

This commit is contained in:
Kevin Frantz 2019-02-25 19:59:55 +01:00
parent 463003f029
commit 6d146c8478
7 changed files with 170 additions and 0 deletions

View File

@ -0,0 +1,35 @@
<?php
namespace Infinito\Attribut;
use Doctrine\Common\Collections\Collection;
use Infinito\Entity\Meta\History\LogInterface;
/**
* @author kevinfrantz
*
* @see LogsAttributInterface
*/
trait LogsAttribut
{
/**
* @var Collection|LogInterface[]
*/
protected $logs;
/**
* @param Collection|LogInterface[] $logs
*/
public function setLogs(Collection $logs): void
{
$this->logs = $logs;
}
/**
* @return Collection|LogInterface[]
*/
public function getLogs(): Collection
{
return $this->logs;
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace Infinito\Attribut;
use Doctrine\Common\Collections\Collection;
use Infinito\Entity\Meta\History\LogInterface;
/**
* @author kevinfrantz
*/
interface LogsAttributInterface
{
/**
* @var string
*/
const LOGS_ATTRIBUT_NAME = 'logs';
/**
* @param Collection|LogInterface[] $logs
*/
public function setLogs(Collection $logs): void;
/**
* @return Collection|LogInterface[]
*/
public function getLogs(): Collection;
}

View File

@ -0,0 +1,37 @@
<?php
namespace Infinito\Attribut;
use Infinito\Exception\AllreadySetException;
/**
* @author kevinfrantz
*
* @see TimestampAttributInterface
*/
trait TimestampAttribut
{
/**
* @var \DateTime
*/
protected $timestamp;
/**
* @param \DateTime $datetime
*/
public function setTimestamp(\DateTime $timestamp): void
{
if (isset($this->timestamp)) {
throw new AllreadySetException('The timestamp is allready set. An Update is not possible!');
}
$this->timestamp = $timestamp;
}
/**
* @return \DateTime
*/
public function getTimestamp(): \DateTime
{
return $this->timestamp;
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace Infinito\Attribut;
/**
* @author kevinfrantz
*/
interface TimestampAttributInterface
{
/**
* @var string
*/
const TIMESTAMP_ATTRIBUT_NAME = 'timestamp';
/**
* @param \DateTime $datetime
*/
public function setTimestamp(\DateTime $timestamp): void;
/**
* @return \DateTime
*/
public function getTimestamp(): \DateTime;
}

View File

@ -0,0 +1,14 @@
<?php
namespace Infinito\Entity\Meta\History;
use Infinito\Entity\Meta\AbstractMeta;
use Infinito\Attribut\LogsAttribut;
/**
* @author kevinfrantz
*/
final class Journal extends AbstractMeta implements JournalInterface
{
use LogsAttribut;
}

View File

@ -0,0 +1,15 @@
<?php
namespace Infinito\Entity\Meta\History;
use Infinito\Attribut\LogsAttributInterface;
use Infinito\Entity\Meta\MetaInterface;
/**
* Containes the logs with the action which are comited to a source.
*
* @author kevinfrantz
*/
interface JournalInterface extends LogsAttributInterface, MetaInterface
{
}

View File

@ -0,0 +1,18 @@
<?php
namespace Infinito\Entity\Meta\History;
use Infinito\Entity\EntityInterface;
use Infinito\Attribut\ActionTypeAttributInterface;
use Infinito\Attribut\RecieverAttributInterface;
use Infinito\Attribut\SourceAttributInterface;
use Infinito\Attribut\TimestampAttributInterface;
/**
* Containes a log entry to every request wich is handled by infinito.
*
* @author kevinfrantz
*/
interface LogInterface extends EntityInterface, ActionTypeAttributInterface, RecieverAttributInterface, SourceAttributInterface, TimestampAttributInterface
{
}