CRUDlex\FileProcessorInterface

interface FileProcessorInterface

This interface is used to handle file uploads.

createFile(Request $request, Entity $entity, $entityName, $field)

Creates the uploaded file of a newly created entity.

Parameters:
  • $request (Request) – the HTTP request containing the file data
  • $entity (Entity) – the just created entity
  • $entityName (string) – the name of the entity as this class here is not aware of it
  • $field (string) – the file field
Returns:

void

updateFile(Request $request, Entity $entity, $entityName, $field)

Updates the uploaded file of an updated entity.

Parameters:
  • $request (Request) – the HTTP request containing the file data
  • $entity (Entity) – the updated entity
  • $entityName (string) – the name of the entity as this class here is not aware of it
  • $field (string) – the file field
Returns:

void

deleteFile(Entity $entity, $entityName, $field)

Deletes a specific file from an existing entity.

Parameters:
  • $entity (Entity) – the entity to delete the file from
  • $entityName (string) – the name of the entity as this class here is not aware of it
  • $field (string) – the field of the entity containing the file to be deleted
Returns:

void

renderFile(Entity $entity, $entityName, $field)

Renders (outputs) a file of an entity. This includes setting headers like the file size, mimetype and name, too.

Parameters:
  • $entity (Entity) – the entity to render the file from
  • $entityName (string) – the name of the entity as this class here is not aware of it
  • $field (string) – the field of the entity containing the file to be rendered
Returns:

SymfonyComponentHttpFoundationResponse the HTTP response, likely to be a streamed one