本文整理汇总了PHP中Drupal\Component\Utility\Random::word方法的典型用法代码示例。如果您正苦于以下问题:PHP Random::word方法的具体用法?PHP Random::word怎么用?PHP Random::word使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Component\Utility\Random
的用法示例。
在下文中一共展示了Random::word方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateSampleValue
/**
* {@inheritdoc}
*/
public static function generateSampleValue(FieldDefinitionInterface $field_definition)
{
$random = new Random();
$max = $field_definition->getSetting('max_length');
$values['value'] = $random->word(mt_rand(1, $max));
return $values;
}
示例2: generateSampleValue
/**
* {@inheritdoc}
*/
public static function generateSampleValue(FieldDefinitionInterface $field_definition)
{
$random = new Random();
if ($field_definition->getItemDefinition()->getSetting('link_type') & LinkItemInterface::LINK_EXTERNAL) {
// Set of possible top-level domains.
$tlds = array('com', 'net', 'gov', 'org', 'edu', 'biz', 'info');
// Set random length for the domain name.
$domain_length = mt_rand(7, 15);
switch ($field_definition->getSetting('title')) {
case DRUPAL_DISABLED:
$values['title'] = '';
break;
case DRUPAL_REQUIRED:
$values['title'] = $random->sentences(4);
break;
case DRUPAL_OPTIONAL:
// In case of optional title, randomize its generation.
$values['title'] = mt_rand(0, 1) ? $random->sentences(4) : '';
break;
}
$values['uri'] = 'http://www.' . $random->word($domain_length) . '.' . $tlds[mt_rand(0, sizeof($tlds) - 1)];
} else {
$values['uri'] = 'base:' . $random->name(mt_rand(1, 64));
}
return $values;
}
示例3: generateSampleValue
/**
* {@inheritdoc}
*/
public static function generateSampleValue(FieldDefinitionInterface $field_definition)
{
// Set random length for the path.
$domain_length = mt_rand(7, 15);
$random = new Random();
$values['path'] = 'http://www.' . $random->word($domain_length);
return $values;
}
示例4: generateSampleValue
/**
* {@inheritdoc}
*/
public static function generateSampleValue(FieldDefinitionInterface $field_definition)
{
$random = new Random();
$values['value'] = $random->word(mt_rand(1, 50));
return $values;
}