public function getOriginal(Entity\Relations $entity)
    {
        foreach ($this as $k => $existing) {
            if (
                $existing->getFromId() == $entity->getFromId() &&
                $existing->getFromContenttype() === $entity->getFromContenttype() &&
                $existing->getToContenttype() === $entity->getToContenttype() &&
                $existing->getToId() == $entity->getToId()
            ) {
                return $existing;
            }
        }

        return $entity;
    }
public function getOriginal(Entity\Relations $entity)
    {
        foreach ($this as $k => $existing) {
            if (
                $existing->getFromId() == $entity->getFromId() &&
                $existing->getFromContenttype() === $entity->getFromContenttype() &&
                $existing->getToContenttype() === $entity->getToContenttype() &&
                $existing->getToId() == $entity->getToId()
            ) {
                return $existing;
            }
        }

        return $entity;
    }
public function getOriginal ( Entity \ Relations $ entity ) { foreach ( $ this as $ k => $ existing ) { if ( $ existing -> getFromId ( ) == $ entity -> getFromId ( ) && $ existing -> getFromContenttype ( ) === $ entity -> getFromContenttype ( ) && $ existing -> getToContenttype ( ) === $ entity -> getToContenttype ( ) && $ existing -> getToId ( ) == $ entity -> getToId ( ) ) { return $ existing ; } } return $ entity ; }
This loops over the existing collection to see if the properties in the incoming
are already available on a saved record. To do this it checks the four key properties
if there's a match it returns the original, otherwise
it returns the new and adds the new one to the collection.

@param Entity\Relations $entity

@return mixed|null
This loops over the existing collection to see if the properties in the incoming are already available on a saved record . To do this it checks the four key properties if there s a match it returns the original otherwise it returns the new and adds the new one to the collection .