Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Concatenate object property with string in hautelook/AliceBundle

I'm using Alice in a Symfony 2 bundle to load fixtures. I'm trying to customize the name of an entity using the name of a parent entity. Specifically, I have an entity, @Report1, whose @Report1->name property returns Test Report 1.

I'm trying to create a child entity with the name Test Report 1 Scenario 1. Here's my fixture file snippet:

AppBundle\Entity\Scenario:
  Scenario1:
    report_id: @Report1->id
    name: @Report1->name 'Scenario 1'

All I get back is the literal @Report1->name 'Scenario 1'.

If I remove the 'Scenario 1' string from thename: property, I get the parent report's actual name.

like image 637
Blake B. Avatar asked Oct 19 '25 04:10

Blake B.


1 Answers

Another option that worked for me was using sprintf:

App\Entity\User:
  users{1..150}:
    firstname: '<firstname()>'
    lastname: '<lastname()>'
    email: '<sprintf("%s.%[email protected]", @self->firstname, @self->lastname)>'
like image 68
ferdynator Avatar answered Oct 21 '25 16:10

ferdynator



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!