I'm seeking for best practice, some logic solution where to store some fake files (images) for data fixtures, which I load with Vich Bundle.
Now I'm storing fake image for posts in src/App/BlogBundle/Resources/public/images/fixtures
But may be It should be another place?
class LoadBlogPostData extends AbstractFixture implements OrderedFixtureInterface
{
/**
* {@inheritDoc}
*/
public function load(ObjectManager $manager)
{
// Create new Blog Post 1
$post1 = new BlogPost();
$post1->setPostTitle('Pellentesque habitant morbi tristique senectus e');
copy(__DIR__ . '/../../Resources/public/images/fixtures/news-flat-image.png',__DIR__ . '/../../Resources/public/images/fixtures/news-flat-image-copy1.png');
$file1 = new UploadedFile(__DIR__ . '/../../Resources/public/images/fixtures/news-flat-image-copy1.png','news-flat-image.png', null, null, null, true);
$post1->setPostImageFile($file1);
$post1->setPostBody('Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus');
$manager->persist($post1);
// Create new Blog Post 2
Aucun commentaire:
Enregistrer un commentaire