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.
49 lines
1.1 KiB
49 lines
1.1 KiB
<?php |
|
|
|
namespace core\services; |
|
|
|
use core\entities\Settings; |
|
use core\forms\SettingsForm; |
|
use core\repositories\SettingsRepository; |
|
|
|
class SettingsService |
|
{ |
|
private $repository; |
|
|
|
public function __construct(SettingsRepository $repository) |
|
{ |
|
$this->repository = $repository; |
|
} |
|
|
|
public function create(SettingsForm $form): Settings |
|
{ |
|
$settings = Settings::create( |
|
$form->type, |
|
$form->section, |
|
$form->key, |
|
$form->value, |
|
$form->active |
|
); |
|
$this->repository->save($settings); |
|
return $settings; |
|
} |
|
|
|
public function edit($id, SettingsForm $form): void |
|
{ |
|
$settings = $this->repository->get($id); |
|
$settings->edit( |
|
$form->type, |
|
$form->section, |
|
$form->key, |
|
$form->value, |
|
$form->active |
|
); |
|
$this->repository->save($settings); |
|
} |
|
|
|
public function remove($id): void |
|
{ |
|
$settings = $this->repository->get($id); |
|
$this->repository->remove($settings); |
|
} |
|
} |