php-solution/file-storage-bundle

This bundle provides an additional functionality for work with files

v0.1.5 2018-05-03 08:35 UTC

This package is auto-updated.

Last update: 2020-11-27 20:23:27 UTC


README

Install

$ composer require php-solution/file-storage-bundle

Usage

  1. Add bundle to your application

  2. Create AbstractFile:

<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use PhpSolution\Doctrine\Entity\IdGeneratedTrait;
use PhpSolution\FileStorageBundle\Entity\AbstractUploadedFile;
use PhpSolution\StdLib\FrequentField\Interfaces\IdentifiableInterface;

/**
 * @ORM\Entity()
 * @ORM\Table(name="file")
 * @ORM\InheritanceType("SINGLE_TABLE")
 * @ORM\DiscriminatorColumn(name="type", type="string")
 */
abstract class AbstractFile extends AbstractUploadedFile implements IdentifiableInterface
{
    use IdGeneratedTrait;
}
  1. Create CustomFile. And implement getStorageBucket function
<?php

namespace AppBundle\Entity;

use AppBundle\Entity\AbstractFile;

/**
 * CustomFile
 */
class CustomFile extends AbstractFile
{
    /**
     * @return string
     */
    public function getStorageBucket(): string
    {
        return 'custom';
    }
}