You are here

public function InstapageCmsPluginPageModel::getRandomSlug in Instapage plugin 8.3

Same name and namespace in other branches
  1. 7.3 core/models/InstapageCmsPluginPageModel.php \InstapageCmsPluginPageModel::getRandomSlug()

Composes a random slug.

Parameters

bool $prefix Do you want to add a prefix?:

Return value

string Random slug.

File

core/models/InstapageCmsPluginPageModel.php, line 597

Class

InstapageCmsPluginPageModel
Class responsible for managing the landing pages.

Code

public function getRandomSlug($prefix = true) {
  $randomPrefix = 'random-url-';
  $randomSufixSet = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  $randomSufixLength = 10;
  $randomString = '';
  for ($i = 0; $i < $randomSufixLength; $i++) {
    $randomString .= $randomSufixSet[rand(0, strlen($randomSufixSet) - 1)];
  }
  return $prefix ? $randomPrefix . $randomString : $randomString;
}