DoctrineFixturesBundle symfony2存储假图像的位置

时间:2015-09-02 12:47:47

标签: image symfony testing fixtures

我正在寻求最佳实践,一些逻辑解决方案,在哪里存储数据夹具的假文件(图像),我加载了Vich Bundle。

现在我在src / App / BlogBu​​ndle / Resources / public / images / fixtures中为帖子存储假图像

但可能应该是另一个地方?

  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

0 个答案:

没有答案