Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use shop\entities\Page;
- class PageRepository
- {
- public function get($id): Page
- {
- if (!$page = Page::findOne($id)) {
- throw new NotFoundException('Страница не найдена.');
- }
- return $page;
- }
- public function save(Page $page): void
- {
- if (!$page->save()) {
- throw new \RuntimeException('Ошибка при сохранении.');
- }
- }
- public function remove(Page $page): void
- {
- if (!$page->delete()) {
- throw new \RuntimeException('Ошибка при удалении.');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement