How can I parse the Symfony parameter in Alice's fixtures.yml file

I am stuck with the nelmio / alice package (expressive light generator). I don't know how to parse a parameter from a shared file config/parameters.yml

(in my case "photoupload_directory") into fixtures.yml

.

Now I have something tough like this:

photo: <Image('/Users/vivi/projects.2016/cvsymfony.local/storage/uploads/photos',1080,800,false,false)>

...

I've already tried:

photo: <Image(getParameter('photoupload_directory'),1080,800,false,false)>

but that doesn't work either. I have also tried

$this->getParameter and $this->getContainer()->getParameter

or designation %photoupload_directory%

).

I have already searched the Internet, but have not found anything yet.

+3


source to share


1 answer


Yes finally one solution, maybe more (for parsing parameters to this class), so if you know, let me know. Below worked for me.

First add the ContainerAwareInterface namespace:

use Symfony\Component\DependencyInjection\ContainerAwareInterface;

      

Add a trait (in class):

use \Symfony\Component\DependencyInjection\ContainerAwareTrait;

      



Create a function:

public function getPhotoUploadDir()
{
    return $this->container->getParameter('photoupload_directory');
}

      

In the fixtures.yml file

photo: <Image($this->fake('getPhotoUploadDir'),1080,800,false,false)>

      

0


source







All Articles