SHARE
TWEET

Untitled

a guest Nov 19th, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * @var Employee[]|EmployeeGroup[] $newAssignees
  3.  * @var Employee[]|EmployeeGroup[] $oldAssignees
  4.  * @return array
  5.  */
  6. private function getAssigneesTypes($oldAssignees, $newAssignees) {
  7.     $deleted = [];
  8.     $added = [];
  9.     $modified = [];
  10.  
  11.     foreach ($oldAssignees as $old) {
  12.         $mod = false;
  13.         foreach ($newAssignees as $new) {
  14.             if ($old->getId() == $new->getId()) {
  15.                 $modified[] = $old;
  16.                 $mod = true;
  17.             }
  18.         }
  19.  
  20.         if (!$mod) {
  21.             $deleted[] = $old;
  22.         }
  23.     }
  24.  
  25.     foreach ($newAssignees as $new) {
  26.         $mod = false;
  27.         foreach ($oldAssignees as $old) {
  28.             if ($old->getId() == $new->getId()) {
  29.                 $mod = true;
  30.             }
  31.         }
  32.  
  33.         if (!$mod) {
  34.             $added[] = $new;
  35.         }
  36.     }
  37.  
  38.     return [
  39.         'deleted' => $deleted,
  40.         'added' => $added,
  41.         'modified' => $modified,
  42.     ];
  43. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top