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.
31 lines
688 B
31 lines
688 B
6 years ago
|
<?php
|
||
|
|
||
|
namespace common\modules\banners\repositories;
|
||
|
|
||
|
use common\modules\banners\entities\Banner;
|
||
|
use core\repositories\NotFoundException;
|
||
|
|
||
|
class BannerRepository
|
||
|
{
|
||
|
public function get($id): Banner
|
||
|
{
|
||
|
if (!$banner = Banner::findOne($id)) {
|
||
|
throw new NotFoundException('Banner is not found.');
|
||
|
}
|
||
|
return $banner;
|
||
|
}
|
||
|
|
||
|
public function save(Banner $banner): void
|
||
|
{
|
||
|
if (!$banner->save()) {
|
||
|
throw new \RuntimeException('Saving error.');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function remove(Banner $banner): void
|
||
|
{
|
||
|
if (!$banner->delete()) {
|
||
|
throw new \RuntimeException('Removing error.');
|
||
|
}
|
||
|
}
|
||
|
}
|