34 lines
727 B
PHP
34 lines
727 B
PHP
<?php
|
|
namespace Szurubooru\Dao;
|
|
|
|
class GlobalParamDao extends AbstractDao implements ICrudDao
|
|
{
|
|
public function __construct(\Szurubooru\DatabaseConnection $databaseConnection)
|
|
{
|
|
parent::__construct(
|
|
$databaseConnection,
|
|
'globals',
|
|
new \Szurubooru\Dao\EntityConverters\GlobalParamEntityConverter());
|
|
}
|
|
|
|
public function save(&$entity)
|
|
{
|
|
if (!$entity->getId())
|
|
{
|
|
$otherEntityWithThisKey = $this->findByKey($entity->getKey());
|
|
if ($otherEntityWithThisKey)
|
|
$entity->setId($otherEntityWithThisKey->getId());
|
|
}
|
|
parent::save($entity);
|
|
}
|
|
|
|
public function findByKey($key)
|
|
{
|
|
return $this->findOneBy('key', $key);
|
|
}
|
|
|
|
public function deleteByKey($key)
|
|
{
|
|
return $this->deleteBy('key', $key);
|
|
}
|
|
}
|