     1: <?php
     2:
     3: /*
     4:  * This file is part of the CRUDlex package.
     5:  *
     6:  * (c) Philip Lehmann-Böhm <philip@philiplb.de>
     7:  *
     8:  * For the full copyright and license information, please view the LICENSE
     9:  * file that was distributed with this source code.
    10:  */
    11:
    12: namespace CRUDlex;
    13:
    14: use Symfony\Component\HttpFoundation\Request;
    15:
    16: use CRUDlex\CRUDEntity;
    17:
    18: /**
    19:  * This interface is used to handle file uploads.
    20:  */
    21: interface CRUDFileProcessorInterface {
    22:
    23:     /**
    24:      * Creates the uploaded file of a newly created entity.
    25:      *
    26:      * @param Request $request
    27:      * the HTTP request containing the file data
    28:      * @param CRUDEntity $entity
    29:      * the just created entity
    30:      * @param string $entityName
    31:      * the name of the entity as this class here is not aware of it
    32:      * @param string $field
    33:      * the file field
    34:      */
    35:     public function createFile(Request $request, CRUDEntity $entity, $entityName, $field);
    36:
    37:     /**
    38:      * Updates the uploaded file of an updated entity.
    39:      *
    40:      * @param Request $request
    41:      * the HTTP request containing the file data
    42:      * @param CRUDEntity $entity
    43:      * the updated entity
    44:      * @param string $entityName
    45:      * the name of the entity as this class here is not aware of it
    46:      * @param string $field
    47:      * the file field
    48:      */
    49:     public function updateFile(Request $request, CRUDEntity $entity, $entityName, $field);
    50:
    51:     /**
    52:      * Deletes a specific file from an existing entity.
    53:      *
    54:      * @param CRUDEntity $entity
    55:      * the entity to delete the file from
    56:      * @param string $entityName
    57:      * the name of the entity as this class here is not aware of it
    58:      * @param string $field
    59:      * the field of the entity containing the file to be deleted
    60:      */
    61:     public function deleteFile(CRUDEntity $entity, $entityName, $field);
    62:
    63:     /**
    64:      * Renders (outputs) a file of an entity. This includes setting headers
    65:      * like the file size, mimetype and name, too.
    66:      *
    67:      * @param CRUDEntity $entity
    68:      * the entity to render the file from
    69:      * @param string $entityName
    70:      * the name of the entity as this class here is not aware of it
    71:      * @param string $field
    72:      * the field of the entity containing the file to be rendered
    73:      *
    74:      * @return Response
    75:      * the HTTP response, likely to be a streamed one
    76:      */
    77:     public function renderFile(CRUDEntity $entity, $entityName, $field);
    78: }
    79: