/** * Merge the translations of two translations. * * @param Translations $from * @param Translations $to * @param int $options */ public static function mergeTranslations(Translations $from, Translations $to, $options = self::DEFAULTS) { if ($options & self::REMOVE) { $filtered = []; foreach ($to as $entry) { if ($from->find($entry)) { $filtered[$entry->getId()] = $entry; } } $to->exchangeArray($filtered); } foreach ($from as $entry) { if ($existing = $to->find($entry)) { $existing->mergeWith($entry); } elseif ($options & self::ADD) { $to[] = $entry; } } }