I want to create Article fixtures for my project which uses Doctrine2 and Symfony 2.2.
Here is how articles are created:
They don't link to images directly but instead they contain image names. Before saving an article my ArticleManager
parses article text, finding image names, searching for those images in database and replacing image markup part with real image path, for example.
This is article content
typed in form
and it contains an
![Image description](Here is My Awesome Image Name)
Then when form is submitted and ArticleManager->save($article)
is called, article manager changes image markup by real file WEB path:
This is article content
typed in form
![Image description](/path/to/my_awesome_image.png)
The problem: ArticleManager
relies on Assetic assets helper
service to build full web image paths and that service resides in request
scope. On the other hand, Doctrine fixtures
are ran from CLI so they can't access that service, making me unable to get image paths when loading article fixture.
Can anyone suggest me the least hackish way of tackling this problem?