You are here

function _redirect_generate_url in Redirect 8

Same name and namespace in other branches
  1. 7.2 redirect.generate.inc \_redirect_generate_url()
  2. 7 redirect.generate.inc \_redirect_generate_url()
1 call to _redirect_generate_url()
redirect_generate_batch_generate in ./redirect.generate.inc

File

./redirect.generate.inc, line 180
Generate callbacks for the redirect module.

Code

function _redirect_generate_url($external = FALSE, $max_levels = 2) {
  $url = [];
  if ($external) {
    $tlds = [
      'com',
      'net',
      'org',
    ];
    $url[] = 'http://www.example.' . $tlds[array_rand($tlds)];
  }
  $max_levels = mt_rand($external ? 0 : 1, $max_levels);
  for ($i = 1; $i <= $max_levels; $i++) {
    $url[] = DevelGenerateBase::generateWord(mt_rand(6 / $i, 8));
  }
  return implode('/', $url);
}