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.
57 lines
1.3 KiB
57 lines
1.3 KiB
<?php |
|
|
|
namespace core\services; |
|
|
|
use core\components\favicon\FaviconGenerator; |
|
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, |
|
$form->type, |
|
$form->section, |
|
$form->key, |
|
$form->active |
|
); |
|
$this->_repository->save($settings); |
|
|
|
return $settings; |
|
} |
|
|
|
public function edit($section, $key, SettingsForm $form): void |
|
{ |
|
$settings = $this->_repository->get($section, $key); |
|
$settings->edit( |
|
$form, |
|
$form->type, |
|
$form->section, |
|
$form->key, |
|
$form->active |
|
); |
|
$this->_repository->save($settings); |
|
} |
|
|
|
public function remove($section, $key): void |
|
{ |
|
$settings = $this->_repository->get($section, $key); |
|
$this->_repository->remove($settings); |
|
} |
|
|
|
public function newFavicon(): void |
|
{ |
|
$fg = new FaviconGenerator(); |
|
$fg->generateIcons(); |
|
} |
|
}
|
|
|