|
|
|
<?php
|
|
|
|
|
|
|
|
namespace common\modules\banners\services;
|
|
|
|
|
|
|
|
use common\modules\banners\entities\BannerPlace;
|
|
|
|
use common\modules\banners\forms\BannerPlaceForm;
|
|
|
|
use common\modules\banners\repositories\BannerPlaceRepository;
|
|
|
|
|
|
|
|
class BannerPlaceManageService
|
|
|
|
{
|
|
|
|
private $_repository;
|
|
|
|
|
|
|
|
public function __construct(BannerPlaceRepository $repository)
|
|
|
|
{
|
|
|
|
$this->_repository = $repository;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function create(BannerPlaceForm $form): BannerPlace
|
|
|
|
{
|
|
|
|
$place = BannerPlace::create(
|
|
|
|
$form->title,
|
|
|
|
$form->width,
|
|
|
|
$form->height,
|
|
|
|
$form->active
|
|
|
|
);
|
|
|
|
$this->_repository->save($place);
|
|
|
|
|
|
|
|
return $place;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function edit($id, BannerPlaceForm $form): void
|
|
|
|
{
|
|
|
|
$place = $this->_repository->get($id);
|
|
|
|
$place->edit(
|
|
|
|
$form->title,
|
|
|
|
$form->width,
|
|
|
|
$form->height,
|
|
|
|
$form->active
|
|
|
|
);
|
|
|
|
$this->_repository->save($place);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function remove($id): void
|
|
|
|
{
|
|
|
|
$place = $this->_repository->get($id);
|
|
|
|
$this->_repository->remove($place);
|
|
|
|
}
|
|
|
|
}
|