Пример #1
0
 public function lesson($groupId)
 {
     $groupRepository = new GroupRepository($this->storage);
     $userGroupRepository = new UserGroups($this->storage);
     $group = $groupRepository->getById($groupId);
     $userGroup = $userGroupRepository->getByGroupForUser($group, $this->currentUser);
     return ['group' => $group, 'fiche' => $userGroup->getNextFiche()];
 }
Пример #2
0
 private function save(Group $group = null)
 {
     $groupRepository = new GroupRepository($this->storage);
     try {
         if (empty($group)) {
             $groupName = new GroupName($this->request->get('name'));
             $group = new Group(new UniqueId(), $this->getCurrentUser(), $groupName, new Fiches($this->storage));
             $groupRepository->insert($group);
             $userGroupsRepository = new UserGroups($this->storage);
             $userGroupsRepository->insert($group, $this->currentUser);
         } else {
             $group->setName(new GroupName($this->request->get('name')));
             $groupRepository->update($group);
         }
     } catch (DataNotValid $e) {
         return ['messages' => ['field' => $e->getFieldName(), 'message' => $e->getMessage()], 'data' => ['name' => $this->request->get('name')]];
     }
     return $this->app->redirect('/groups');
 }