Check if there is already a database entry with this url segment

@param string $urlSegment
@param int $id
@return bool
173850
protected function lookForExistingURLSegment($urlSegment, $id) {
        return $this->owner->get()->filter(
            'URLSegment', $urlSegment
        )->exclude('ID', is_null($id) ? 0 : $id)->exists();
    }
907296
public boolean waitForFragmentById(int id, int timeout){
		if(config.commandLogging){
			Log.d(config.commandLoggingTag, "waitForFragmentById("+id+", "+timeout+")");
		}
		
		return waiter.waitForFragment(null, id, timeout);
	}
268251
public static function removeUrlSegment($url, $segment, $replacement = '/')
    {
        $preparedSegment = trim($segment, '/');
        if (empty($preparedSegment)) {
            return $url;
        }
        preg_match('/^([^?]+?)(\?.+?)?$/', $url, $matches); // get url and get apart
        return preg_replace(
                '/(?:\/|^)' . $preparedSegment . '(?:\/|$)/i',
                $replacement,
                (isset($matches[1]) ? $matches[1] : '')
            ) . (isset($matches[2]) ? $matches[2] : '');
    }
132021
public function contain(string $id): bool
    {
        if ($this->properties()->containSection($id)) {
            return true;
        }

        return $this->hasFallback();
    }
292045
protected void selectSegment(Segment segment) {
    if(segment.isUnpaired()) {
      // remember selected unpaired segment
      for(Segment other : segments.getPairedSegments(segment)) {
        indirectSelections.put(other, segment);
        selectSegment(other);
      }
    }
    else {
      if(!selectedSegments.contains(segment)) {
        selectedSegments.add(segment);
        if(segment.getDBIDs() != null) {
          unselectedObjects.removeDBIDs(segment.getDBIDs());
        }
      }
    }
  }
898859
public function setNodeSegment(NodeInterface $node, string $segment, ?string $previous = null) : void
    {
        if ($this->isNodeBlacklisted($node)) {
            return;
        }

        if (!$previous) {
            $previous = $this->getNodeSegment($node);
        }
        if (empty($segment)) {
            $segment = null;
        }

        if ($previous === $segment) {
            return; // Nothing to do
        }

        $this
            ->database
            ->merge('ucms_seo_node')
            ->key(['nid' => $node->id()])
            ->fields(['alias_segment' => $segment])
            ->execute()
        ;

        if (empty($segment)) {
            $this->onAliasChange([$node->id()]);
        } else {
            $this->onAliasChange([$node->id()]);
        }
    }
600499
public function segment($id)
    {
        if (in_array($id, array_keys($this->segments))) {
            return $this->segments[$id];
        } else {
            throw new OutOfRangeException("Invalid argument provided, no segment is present with id: $id!");
        }
    }
74785
public function delete($idSegment)
    {
        $segment = $this->getSegmentOrFail($idSegment);
        $this->checkUserCanEditOrDeleteSegment($segment);

        /**
         * Triggered before a segment is deleted or made invisible.
         *
         * This event can be used by plugins to throw an exception
         * or do something else.
         *
         * @param int $idSegment The ID of the segment being deleted.
         */
        Piwik::postEvent('SegmentEditor.deactivate', array($idSegment));

        $this->getModel()->deleteSegment($idSegment);

        return true;
    }
1221967
public static <T extends AbstractJaxb> boolean insertAfterId(String id,
            T insObject, T target) throws TagTypeUnmatchException {
        return execute(OperationEnum.AFTER, id,
                insObject.copy(insObject.getClass()), target);
    }
1103053
private function uriExists(Page $model, $uri, $locale, $id)
    {
        $query = $model->where('uri->'.$locale, $uri);
        if ($id) {
            $query->where('id', '!=', $id);
        }

        if ($query->first()) {
            return true;
        }

        return false;
    }
1116838
public function validURLSegment()
    {
        $conflict = Member::get()->filter('URLSegment', $this->owner->URLSegment);

        if ($this->owner->ID) {
            $conflict = $conflict->exclude('ID', $this->owner->ID);
        }

        return $conflict->count() == 0;
    }
1359374
public function removeElementFromTrash($id)
    {
        try {
            return $this->innerGateway->removeElementFromTrash($id);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
1052957
function pushToEditUrl(sSegment) {
				if (sSegment.includes("($uid=")) {
					prepareKeyPredicate(stripPredicate(sSegment));
				} else {
					aEditUrl.push(sSegment);
				}
			}
1289284
public function initSegment($segment, $configId = false)
    {
        if (!count($segment->getOverviews()->toArray())) {
            if ($configId) {
                $config = $this->getEntityManager()->getRepository('KunstmaanDashboardBundle:AnalyticsConfig')->find($configId);
            } else {
                $config = $this->getEntityManager()->getRepository('KunstmaanDashboardBundle:AnalyticsConfig')->findFirst();
            }
            $this->getEntityManager()->getRepository('KunstmaanDashboardBundle:AnalyticsOverview')->addOverviews($config, $segment);
        }
    }
153491
public function getSuggestedValuesForSegment($segmentName, $idSite)
    {
        if (empty(Config::getInstance()->General['enable_segment_suggested_values'])) {
            return array();
        }

        Piwik::checkUserHasViewAccess($idSite);

        $maxSuggestionsToReturn = 30;
        $segment = $this->findSegment($segmentName, $idSite);

        // if segment has suggested values callback then return result from it instead
        $suggestedValuesCallbackRequiresTable = false;
        if (isset($segment['suggestedValuesCallback'])) {
            $suggestedValuesCallbackRequiresTable = $this->doesSuggestedValuesCallbackNeedData(
                $segment['suggestedValuesCallback']);

            if (!$suggestedValuesCallbackRequiresTable) {
                return call_user_func($segment['suggestedValuesCallback'], $idSite, $maxSuggestionsToReturn);
            }
        }

        // if period=range is disabled, do not proceed
        if (!Period\Factory::isPeriodEnabledForAPI('range')) {
            return array();
        }

        if (!empty($segment['unionOfSegments'])) {
            $values = array();
            foreach ($segment['unionOfSegments'] as $unionSegmentName) {
                $unionSegment = $this->findSegment($unionSegmentName, $idSite);

                try {
                    $result = $this->getSuggestedValuesForSegmentName($idSite, $unionSegment, $maxSuggestionsToReturn);
                    if (!empty($result)) {
                        $values = array_merge($result, $values);
                    }
                } catch (\Exception $e) {
                    // we ignore if there was no data found for $unionSegmentName
                }
            }

            if (empty($values)) {
                throw new \Exception("There was no data to suggest for $segmentName");
            }

        } else {
            $values = $this->getSuggestedValuesForSegmentName($idSite, $segment, $maxSuggestionsToReturn);
        }

        $values = $this->getMostFrequentValues($values);
        $values = array_slice($values, 0, $maxSuggestionsToReturn);
        $values = array_map(array('Piwik\Common', 'unsanitizeInputValue'), $values);

        return $values;
    }
922109
protected function checkUrlNode(\DOMNode $urlNode)
    {
        $hasLocalization = (null != $urlNode->attributes->getNamedItem('localization'))
            || (false !== strpos($urlNode->nodeValue, '{localization}'));

        $hasLanguage = (null != $urlNode->attributes->getNamedItem('language'))
            || (false !== strpos($urlNode->nodeValue, '{language}'))
            || $hasLocalization;

        $hasSegment = (0 == count($this->webspace->getSegments()))
            || (null != $urlNode->attributes->getNamedItem('segment'))
            || (false !== strpos($urlNode->nodeValue, '{segment}'));

        $hasRedirect = (null != $urlNode->attributes->getNamedItem('redirect'));

        return ($hasLanguage && $hasSegment) || $hasRedirect;
    }
709442
public function exists($id)
    {
        if (array_key_exists($id, $this->components)) {
            return true;
        }

        if (isset($this->instances[$id])) {
            return true;
        }

        return false;
    }