本文整理汇总了PHP中Faker\Generator::imageUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Generator::imageUrl方法的具体用法?PHP Generator::imageUrl怎么用?PHP Generator::imageUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Faker\Generator
的用法示例。
在下文中一共展示了Generator::imageUrl方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
public function load(ObjectManager $manager)
{
$user = $manager->getRepository('TaichiUserBundle:User')->findOneBy(['username' => 'heaven']);
foreach (range(1, self::POST_NUMS) as $i) {
$post = new Post();
$categories = $manager->getRepository('TaichiBlogBundle:Category')->findAll();
$categoryIds = [];
foreach ($categories as $category) {
$categoryIds[] = $category->getId();
}
$cIdKey = array_rand($categoryIds, 1);
$category = $manager->getRepository('TaichiBlogBundle:Category')->find($categoryIds[$cIdKey]);
$post->setSubject(implode(' ', array_map('ucfirst', $this->faker->words(mt_rand(3, 5)))));
$post->setAbstract($this->faker->paragraph(mt_rand(2, 4)));
$post->setContent($this->faker->paragraph(mt_rand(6, 10)));
$post->setUser($user);
$post->setCategory($category);
//Add tags
$tags = $manager->getRepository('TaichiBlogBundle:Tag')->findAll();
$tagIds = [];
foreach ($tags as $tag) {
$tagIds[] = $tag->getId();
}
$tIdKeys = array_rand($tagIds, mt_rand(2, 5));
foreach ($tIdKeys as $tIdKey) {
$tag = $manager->getRepository('TaichiBlogBundle:Tag')->find($tagIds[$tIdKey]);
$post->addTag($tag);
}
$post->setPictureUrl($this->faker->imageUrl(400, 240));
$post->setCreatedAt($this->faker->dateTimeBetween('-1 year', '-10 days'));
$post->setUpdatedAt($post->getCreatedAt());
foreach (range(1, mt_rand(1, self::COMMENT_NUMS)) as $j) {
$comment = new Comment();
$comment->setUser($user);
$comment->setCreatedAt($this->faker->dateTimeBetween($post->getCreatedAt(), 'now'));
$comment->setUpdatedAt($comment->getCreatedAt());
$comment->setContent($this->faker->paragraph(mt_rand(1, 3)));
$comment->setPost($post);
$manager->persist($comment);
$post->addComment($comment);
}
$manager->persist($post);
}
$manager->flush();
}
示例2: resolveConfigType
private function resolveConfigType($config)
{
switch ($config['type']) {
case "url":
return $this->faker->url;
case "image":
$width = isset($config['options']['width']) ? $config['options']['width'] : 800;
$height = isset($config['options']['height']) ? $config['options']['height'] : 400;
return $this->faker->imageUrl($width, $height);
case "page_select":
$page = ['title' => $this->faker->sentence(), 'body' => $this->faker->text(6000), 'slug' => $this->faker->slug, 'created' => $this->faker->date()];
return $page;
case "product_category_select":
case "collection_select":
$category = ["name" => $this->faker->word, "slug" => $this->faker->slug];
return $category;
case "product_select":
return $this->tdk->makeProduct();
default:
return $this->faker->word;
}
}
示例3: getDummyData
public function getDummyData(Generator $faker, array $custom = [])
{
return ['title' => $faker->title, 'favicon_path' => $faker->imageUrl(), 'url' => $faker->url, 'visibility' => $faker->randomElement([1, 1, 1, 0]), 'user_id' => $this->random('User')->id];
}
示例4: create
/**
* Create a new (fake) product
*
* @return Product
*/
protected function create()
{
return new Product($this->faker->sentence(3), $this->faker->imageUrl(), $this->faker->paragraph(3));
}
示例5: getDummyData
public function getDummyData(Generator $faker, array $custom = [])
{
return ['biography' => $faker->paragraph(4), 'twitter' => '@' . $faker->userName, 'path_avatar' => $faker->imageUrl(250, 300, 'people'), 'web' => $faker->domainName, 'user_id' => $faker->unique()->numberBetween(1, 300)];
}
示例6: photoUrl
/**
* Generate URL to a random photo
*
* @param null|string $category
* @param int $width
* @param int $height
* @return string
*/
public function photoUrl($category = null, $width = 640, $height = 480)
{
return $this->faker->imageUrl($width, $height, $category);
}
示例7: getDummyData
public function getDummyData(Generator $faker, array $customValues = array())
{
return ['name' => $faker->company, 'code' => $this->characters[rand(0, strlen($this->characters) - 1)] . $this->characters[rand(0, strlen($this->characters) - 1)] . $this->characters[rand(0, strlen($this->characters) - 1)], 'address' => $faker->address, 'logo' => $faker->imageUrl(120, 120), 'status' => $faker->randomElement([false, false, true])];
}