| @@ 920-931 (lines=12) @@ | ||
| 917 | $this->operator->set($fieldName, $value); |
|
| 918 | } |
|
| 919 | } // field exists and is array |
|
| 920 | else { |
|
| 921 | if ($this->getId()) { |
|
| 922 | $setValue = $this->operator->get('$set', $fieldName); |
|
| 923 | if ($setValue) { |
|
| 924 | $setValue[] = $value; |
|
| 925 | $this->operator->set($fieldName, $setValue); |
|
| 926 | } else { |
|
| 927 | $this->operator->push($fieldName, $value); |
|
| 928 | } |
|
| 929 | } |
|
| 930 | $value = array_merge($oldValue, array($value)); |
|
| 931 | } |
|
| 932 | ||
| 933 | // update local data |
|
| 934 | parent::set($fieldName, $value); |
|
| @@ 997-1011 (lines=15) @@ | ||
| 994 | // check if old value is list or sub document |
|
| 995 | // on sub document throw exception |
|
| 996 | throw new InvalidOperationException(sprintf('The field "%s" must be an array but is of type Object', $fieldName)); |
|
| 997 | } else { |
|
| 998 | // check if already in set |
|
| 999 | if (in_array($value, $set)) { |
|
| 1000 | return $this; |
|
| 1001 | } |
|
| 1002 | $updatedSet = array_merge($set, array($value)); |
|
| 1003 | if ($this->getId()) { |
|
| 1004 | $setValue = $this->operator->get('$set', $fieldName); |
|
| 1005 | if ($setValue) { |
|
| 1006 | $this->operator->set($fieldName, $updatedSet); |
|
| 1007 | } else { |
|
| 1008 | $this->operator->addToSet($fieldName, $value); |
|
| 1009 | } |
|
| 1010 | } |
|
| 1011 | } |
|
| 1012 | ||
| 1013 | parent::set($fieldName, $updatedSet); |
|
| 1014 | ||