public function _mergeWithPrevious($previous)
    {
        if ($previous == null)
        {
            return $this;
        }
        if ($previous instanceof AVRelationOperation)
        {
            if ($previous->targetClassName != null && $previous->targetClassName != $this->targetClassName
            )
            {
                throw new \Exception('Related object object must be of class ' . $this->targetClassName . ', but ' . $previous->targetClassName . ' was passed in.');
            }
            $newRelationToAdd = self::convertToOneDimensionalArray($this->relationsToAdd);
            $newRelationToRemove = self::convertToOneDimensionalArray($this->relationsToRemove);

            $previous->addObjects($newRelationToAdd, $previous->relationsToAdd);
            $previous->removeObjects($newRelationToAdd, $previous->relationsToRemove);

            $previous->removeObjects($newRelationToRemove, $previous->relationsToAdd);
            $previous->addObjects($newRelationToRemove, $previous->relationsToRemove);

            $newRelationToAdd = self::convertToOneDimensionalArray($previous->relationsToAdd);
            $newRelationToRemove = self::convertToOneDimensionalArray($previous->relationsToRemove);

            return new AVRelationOperation($newRelationToAdd, $newRelationToRemove);
        }
        throw new \Exception('Operation is invalid after previous operation.');
    }
public function _mergeWithPrevious($previous)
    {
        if ($previous == null)
        {
            return $this;
        }
        if ($previous instanceof AVRelationOperation)
        {
            if ($previous->targetClassName != null && $previous->targetClassName != $this->targetClassName
            )
            {
                throw new \Exception('Related object object must be of class ' . $this->targetClassName . ', but ' . $previous->targetClassName . ' was passed in.');
            }
            $newRelationToAdd = self::convertToOneDimensionalArray($this->relationsToAdd);
            $newRelationToRemove = self::convertToOneDimensionalArray($this->relationsToRemove);

            $previous->addObjects($newRelationToAdd, $previous->relationsToAdd);
            $previous->removeObjects($newRelationToAdd, $previous->relationsToRemove);

            $previous->removeObjects($newRelationToRemove, $previous->relationsToAdd);
            $previous->addObjects($newRelationToRemove, $previous->relationsToRemove);

            $newRelationToAdd = self::convertToOneDimensionalArray($previous->relationsToAdd);
            $newRelationToRemove = self::convertToOneDimensionalArray($previous->relationsToRemove);

            return new AVRelationOperation($newRelationToAdd, $newRelationToRemove);
        }
        throw new \Exception('Operation is invalid after previous operation.');
    }
public function _mergeWithPrevious ( $ previous ) { if ( $ previous == null ) { return $ this ; } if ( $ previous instanceof AVRelationOperation ) { if ( $ previous -> targetClassName != null && $ previous -> targetClassName != $ this -> targetClassName ) { throw new \ Exception ( 'Related object object must be of class ' . $ this -> targetClassName . ', but ' . $ previous -> targetClassName . ' was passed in.' ) ; } $ newRelationToAdd = self :: convertToOneDimensionalArray ( $ this -> relationsToAdd ) ; $ newRelationToRemove = self :: convertToOneDimensionalArray ( $ this -> relationsToRemove ) ; $ previous -> addObjects ( $ newRelationToAdd , $ previous -> relationsToAdd ) ; $ previous -> removeObjects ( $ newRelationToAdd , $ previous -> relationsToRemove ) ; $ previous -> removeObjects ( $ newRelationToRemove , $ previous -> relationsToAdd ) ; $ previous -> addObjects ( $ newRelationToRemove , $ previous -> relationsToRemove ) ; $ newRelationToAdd = self :: convertToOneDimensionalArray ( $ previous -> relationsToAdd ) ; $ newRelationToRemove = self :: convertToOneDimensionalArray ( $ previous -> relationsToRemove ) ; return new AVRelationOperation ( $ newRelationToAdd , $ newRelationToRemove ) ; } throw new \ Exception ( 'Operation is invalid after previous operation.' ) ; }
Merge this operation with a previous operation and return the new
operation.

@param FieldOperation $previous Previous operation.

@return FieldOperation Merged operation result.

@throws \Exception
Merge this operation with a previous operation and return the new operation .