/** * @param string|array|MegaMenuItem $url1 * @param string|array $url2 * @return bool */ public function isUrlEquals($url1, $url2) { if ($url1 instanceof MegaMenuItem) { $url1 = $url1->url; } if ($url2 instanceof MegaMenuItem) { $url2 = $url2->url; } // Is routes if ($this->isRoute($url1) && $this->isRoute($url2)) { if (MenuHelper::normalizeRoute($url1[0]) !== MenuHelper::normalizeRoute($url2[0])) { return false; } // Compare routes' parameters by checking if keys are identical if (count(array_diff_key($url1, $url2)) || count(array_diff_key($url2, $url1))) { return false; } foreach ($url1 as $key => $value) { if (is_string($key) && $key !== '#') { if (!array_key_exists($key, $url2)) { return false; } if ($value !== null && $url2[$key] !== null && $url2[$key] !== $value) { return false; } } } return true; } // Is urls if (is_string($url1) && is_string($url2)) { return $url1 === $url2; } return false; }