/**
  * Update state of the lock for User Progression for a step.
  *
  * @param User      $user
  * @param Step      $step
  * @param bool|null $lockedcall
  * @param bool|null $lock
  * @param bool|null $authorized
  *
  * @return object UserProgression
  */
 public function updateLockedState(User $user, Step $step, $lockedcall = null, $lock = null, $authorized = null, $status = '')
 {
     // Retrieve the current progression for this step
     $progression = $this->om->getRepository('InnovaPathBundle:UserProgression')->findOneBy(['step' => $step, 'user' => $user]);
     if ($progression === null) {
         $progression = new UserProgression();
         $progression->setUser($user);
         $progression->setStep($step);
         $progression->setStatus($status);
         $progression->setAuthorized(false);
     }
     //if unlock call has changed
     if ($lockedcall !== null) {
         $progression->setLockedcall($lockedcall);
     }
     //if lock state has changed
     if ($lock !== null) {
         $progression->setLocked($lock);
     }
     //if authorization has changed
     if ($authorized !== null) {
         $progression->setAuthorized($authorized);
     }
     //if status has changed
     if ($status !== null) {
         $progression->setStatus($status);
     }
     $this->om->persist($progression);
     $this->om->flush();
     return $progression;
 }