I am trying to generate a dummy data using AliceBundle for Symfony Framework. Everything seems to be working fine except I am looking for a way to randomly assign data from an array to a property called type
. Looking at the faker library I can see that I can generate that using randomElement($array = array ('a','b','c'))
I am trying to convert that into YML
and I think that is equivalent of
<randomElement(['a','b','c'])>
But this produces an error
[Nelmio\Alice\Throwable\Exception\FixtureBuilder\ExpressionLanguage\LexException] Could not lex the value "['a'".
This is my complete yml
AppBundle\Entity\Job:
job{1..5}:
title: <jobTitle()>
description: <paragraph(3)>
length: "3_months_full_time"
type: <randomElement(['a','b','c'])>
bonus: <paragraph(3)>
expired_at: "2016-12-21"
job_user: "@emp*"
I ended up creating a custom provider
Add that to
services.yml
And then use it in yml file