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.
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace common\modules\forms\services;
|
|
|
|
|
|
|
|
use common\modules\forms\entities\FormMessage;
|
|
|
|
use common\modules\forms\repositories\FormMessageRepository;
|
|
|
|
|
|
|
|
class FormMessageManageService
|
|
|
|
{
|
|
|
|
private $repository;
|
|
|
|
|
|
|
|
public function __construct(FormMessageRepository $repository)
|
|
|
|
{
|
|
|
|
$this->repository = $repository;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function create($form_id, $data): FormMessage
|
|
|
|
{
|
|
|
|
$message = FormMessage::create(
|
|
|
|
$form_id,
|
|
|
|
$data
|
|
|
|
);
|
|
|
|
$this->repository->save($message);
|
|
|
|
return $message;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function edit($id, $form_id, $data): void
|
|
|
|
{
|
|
|
|
$message = $this->repository->get($id);
|
|
|
|
$message->edit(
|
|
|
|
$form_id,
|
|
|
|
$data
|
|
|
|
);
|
|
|
|
$this->repository->save($message);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setRead($id)
|
|
|
|
{
|
|
|
|
$message = $this->repository->get($id);
|
|
|
|
$message->new = 0;
|
|
|
|
$this->repository->save($message);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function remove($id): void
|
|
|
|
{
|
|
|
|
$message = $this->repository->get($id);
|
|
|
|
$this->repository->remove($message);
|
|
|
|
}
|
|
|
|
}
|