You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
636 B
30 lines
636 B
6 years ago
|
<?php
|
||
|
|
||
|
namespace core\repositories;
|
||
|
|
||
|
use core\entities\Settings;
|
||
|
|
||
|
class SettingsRepository
|
||
|
{
|
||
|
public function get($id): Settings
|
||
|
{
|
||
|
if (!$settings = Settings::findOne($id)) {
|
||
|
throw new NotFoundException('Setting is not found.');
|
||
|
}
|
||
|
return $settings;
|
||
|
}
|
||
|
|
||
|
public function save(Settings $settings): void
|
||
|
{
|
||
|
if (!$settings->save()) {
|
||
|
throw new \RuntimeException('Saving error.');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function remove(Settings $settings): void
|
||
|
{
|
||
|
if (!$settings->delete()) {
|
||
|
throw new \RuntimeException('Removing error.');
|
||
|
}
|
||
|
}
|
||
|
}
|