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.

51 lines
1.1 KiB

6 years ago
<?php
namespace core\services;
use core\entities\Settings;
use core\forms\SettingsForm;
use core\repositories\SettingsRepository;
class SettingsService
{
private $_repository;
6 years ago
public function __construct(SettingsRepository $repository)
{
$this->_repository = $repository;
6 years ago
}
public function create(SettingsForm $form): Settings
{
$settings = Settings::create(
$form,
6 years ago
$form->type,
$form->section,
$form->key,
$form->active
);
$this->_repository->save($settings);
6 years ago
return $settings;
}
public function edit($section, $key, SettingsForm $form): void
6 years ago
{
$settings = $this->_repository->get($section, $key);
6 years ago
$settings->edit(
$form,
$form->type,
$form->section,
$form->key,
$form->active
6 years ago
);
$this->_repository->save($settings);
6 years ago
}
public function remove($section, $key): void
6 years ago
{
$settings = $this->_repository->get($section, $key);
$this->_repository->remove($settings);
6 years ago
}
}