Files
core/src/Tools/Model/Saveable.php
T
Basilius Sauter 0ff9958830 Adds MotD and Message model as well as tests
This commit adds the MotD model for storing and retrieving
messages-of-the-day.

It also adds a model for messages. Messages have an author as well as a
thread they belong to, the thread can be read by a specific number of
authors. FUrthermore, the message model supports system messages.

This commit introduces a number of needed changes:
- Character is now implementing the CharacterInterface
- MissingCharacter and SystemCharacter are supporting "pseudo-characters"
- trait MockCharacter implements non-implemented methods for
  MissingCharacter and SytemCharacter
- Characters are now soft-deletable. Models wanting to load soft-deleted
  characters need to fetch them eagerly.

Closes #17
2016-05-12 11:04:04 +02:00

35 lines
835 B
PHP

<?php
declare(strict_types=1);
namespace LotGD\Core\Tools\Model;
use Doctrine\ORM\EntityManagerInterface;
use LotGD\Core\Models\SaveableInterface;
/**
* Provides methods for persisting Saveable entities.
*/
trait Saveable
{
/**
* Static, protected save function to call from trait-overwriting methods.
* @param \LotGD\Core\Tools\Model\CreateableInterface $object
* @param EntityManagerInterface $em
*/
public static function _save(SaveableInterface $object, EntityManagerInterface $em)
{
$em->persist($object);
$em->flush();
}
/**
* Marks the entity as permanent and saves it into the database.
* @param EntityManagerInterface $em The Entity Manager
*/
public function save(EntityManagerInterface $em)
{
self::_save($this, $em);
}
}