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.

58 lines
1.4 KiB

7 years ago
<?php
namespace core\services;
use core\components\favicon\FaviconGenerator;
7 years ago
use core\entities\Settings;
use core\forms\SettingsForm;
use core\repositories\SettingsRepository;
class SettingsService
{
3 years ago
private SettingsRepository $settings_repository;
7 years ago
3 years ago
public function __construct(SettingsRepository $settings_repository)
7 years ago
{
3 years ago
$this->settings_repository = $settings_repository;
7 years ago
}
public function create(SettingsForm $form): Settings
{
$settings = Settings::create(
$form,
7 years ago
$form->type,
$form->section,
$form->key,
$form->active
);
3 years ago
$this->settings_repository->save($settings);
7 years ago
return $settings;
}
public function edit($section, $key, SettingsForm $form): void
7 years ago
{
3 years ago
$settings = $this->settings_repository->get($section, $key);
7 years ago
$settings->edit(
$form,
$form->type,
$form->section,
$form->key,
$form->active
7 years ago
);
3 years ago
$this->settings_repository->save($settings);
7 years ago
}
public function remove($section, $key): void
7 years ago
{
3 years ago
$settings = $this->settings_repository->get($section, $key);
$this->settings_repository->remove($settings);
7 years ago
}
public function newFavicon(): void
{
$fg = new FaviconGenerator();
$fg->generateIcons();
}
}