szurubooru/src/Dao/GlobalParamDao.php
Marcin Kurczewski 632bac8661 Added "use ..." statements
This version ditches backwards compatibility with PHP earlier than 5.6.
2014-10-18 18:48:36 +02:00

36 lines
789 B
PHP

<?php
namespace Szurubooru\Dao;
use Szurubooru\Dao\EntityConverters\GlobalParamEntityConverter;
use Szurubooru\DatabaseConnection;
class GlobalParamDao extends AbstractDao implements ICrudDao
{
public function __construct(DatabaseConnection $databaseConnection)
{
parent::__construct(
$databaseConnection,
'globals',
new 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('dataKey', $key);
}
public function deleteByKey($key)
{
return $this->deleteBy('dataKey', $key);
}
}