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.
30 lines
641 B
30 lines
641 B
6 years ago
|
<?php
|
||
|
|
||
|
namespace core\repositories;
|
||
|
|
||
|
use core\entities\ModuleRecord;
|
||
|
|
||
|
class ModuleRepository
|
||
|
{
|
||
|
public function get($id): ModuleRecord
|
||
|
{
|
||
|
if (!$module = ModuleRecord::findOne($id)) {
|
||
|
throw new NotFoundException('Module is not found.');
|
||
|
}
|
||
|
return $module;
|
||
|
}
|
||
|
|
||
|
public function save(ModuleRecord $module): void
|
||
|
{
|
||
|
if (!$module->save()) {
|
||
|
throw new \RuntimeException('Saving error.');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function remove(ModuleRecord $module): void
|
||
|
{
|
||
|
if (!$module->delete()) {
|
||
|
throw new \RuntimeException('Removing error.');
|
||
|
}
|
||
|
}
|
||
|
}
|