You are here

protected function Candidates::determineLocale in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony-cmf/routing/Candidates/Candidates.php \Symfony\Cmf\Component\Routing\Candidates\Candidates::determineLocale()

Determine the locale of this URL.

Parameters

string $url The url to determine the locale from.:

Return value

string|boolean The locale if $url starts with one of the allowed locales.

1 call to Candidates::determineLocale()
Candidates::getCandidates in vendor/symfony-cmf/routing/Candidates/Candidates.php

File

vendor/symfony-cmf/routing/Candidates/Candidates.php, line 104

Class

Candidates
A straightforward strategy that splits the URL on "/".

Namespace

Symfony\Cmf\Component\Routing\Candidates

Code

protected function determineLocale($url) {
  if (!count($this->locales)) {
    return false;
  }
  $matches = array();
  if (preg_match('#(' . implode('|', $this->locales) . ')(/|$)#', $url, $matches)) {
    return $matches[1];
  }
  return false;
}