szurubooru/src/Dao/GlobalParamDao.php

37 lines
789 B
PHP
Raw Normal View History

2014-09-24 23:24:51 +02:00
<?php
namespace Szurubooru\Dao;
use Szurubooru\Dao\EntityConverters\GlobalParamEntityConverter;
use Szurubooru\DatabaseConnection;
2014-09-24 23:24:51 +02:00
class GlobalParamDao extends AbstractDao implements ICrudDao
{
public function __construct(DatabaseConnection $databaseConnection)
2014-09-24 23:24:51 +02:00
{
parent::__construct(
$databaseConnection,
'globals',
new GlobalParamEntityConverter());
2014-09-24 23:24:51 +02:00
}
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)
{
2014-09-28 16:26:44 +02:00
return $this->findOneBy('dataKey', $key);
2014-09-24 23:24:51 +02:00
}
public function deleteByKey($key)
{
2014-09-28 16:26:44 +02:00
return $this->deleteBy('dataKey', $key);
2014-09-24 23:24:51 +02:00
}
}