コード例 #1
0
 public function setUsers($value)
 {
     if (is_object($value)) {
         $value = json_decode($value);
         foreach ($value as $item) {
             $taskUser = new TaskUser();
             $taskUser->setTask($this);
             $taskUser->setUserId($item->id);
             $this->addUser($taskUser);
         }
     }
 }
コード例 #2
0
ファイル: Task.php プロジェクト: andrewSAY/SimpleMVCFramework
 public function setUsers($value)
 {
     if (is_array($value)) {
         foreach ($value as $item) {
             $taskUser = new TaskUser();
             $taskUser->setTask($this);
             $taskUser->setUserId($item->id);
             $this->addUser($taskUser);
         }
         return;
     }
 }
コード例 #3
0
 public function createTask(User $user, Task $task)
 {
     $dictionary = new Dictionary();
     if ($user->getRole() != $dictionary->userRoles()->ROLE_BOSS[0]) {
         return;
     }
     $this->accessOpened = true;
     $this->task = $task;
     $this->task->setState($dictionary->taskStates()->CREATED[0]);
     $this->dataRepository->persist($this->task);
     $author = new TaskUser();
     $author->setUser($user);
     $author->setRole($dictionary->taskRoles()->CREATOR[0]);
     $author->setTask($this->task);
     $this->dataRepository->persist($author);
     foreach ($task->getUsers() as $userTask) {
         $userTask->setRole($dictionary->taskRoles()->EXECUTOR[0]);
         $userTask->setUser($this->dataRepository->findUser($userTask->getUserId()));
         $this->dataRepository->persist($userTask);
     }
     $this->wasChanged = true;
 }