class ThumbnailMiddleware implements MiddlewareInterface, ApplicationAwareInterface (View source)

Class ThumbnailMiddleware Middleware used to populate thumbnails at the end of each request.

This middleware requires the following to be defined on the Application: "database" DatabaseManager "BasicThumbnailer::class" Basic thumbnailer

Traits

Trait ApplicationAwareTrait A trait used with ApplicationAwareInterface

Properties

protected Application $app from  ApplicationAwareTrait
protected Filesystem $baseFileSystem
private BasicThumbnailer $thumbnailer
private EntityManagerInterface $entityManager
private Connection $connection
private Repository $config

Methods

setApplication(Application $app)

Setter method for the application

__construct(Repository $config)

No description

Response
process(Request $request, DelegateInterface $frame)

Process the request and return a response.

getThumbnailer()

No description

EntityManagerInterface
getEntityManager()

No description

getConnection()

No description

Response
buildRedirectToThumbnailResponse(Request $request)

No description

array|null
getThumbnailToGenerate(Connection $database, string|null $searchThumbnailPath = null)

No description

bool
generateThumbnail(array $thumbnail)

Generate a thumbnail.

bool
attemptBuild(File $file, array $thumbnail)

Try building an unbuilt thumbnail.

array
getDimensions(array $thumbnail)

Get the dimensions out of a thumbnail array.

bool
isBuilt(File $file, array $thumbnail)

No description

Connection|null
tryGetConnection()

No description

markThumbnailAsBuilt(Connection $connection, array $thumbnail, bool $built = true)

Mark a thumbnail as built or not.

bool
couldBeTheRequestedThumbnail(array $thumbnail, string|null $searchThumbnailPath)

Check if a thumbnail array may be for the requested path.

failBuild(File $file, array $thumbnail)

Mark the build failed.

Details

setApplication(Application $app)

Setter method for the application

Parameters

Application $app

__construct(Repository $config)

No description

Parameters

Repository $config

Response process(Request $request, DelegateInterface $frame)

Process the request and return a response.

Parameters

Request $request
DelegateInterface $frame

Return Value

Response

protected BasicThumbnailer getThumbnailer()

No description

Return Value

BasicThumbnailer

protected EntityManagerInterface getEntityManager()

No description

Return Value

EntityManagerInterface

protected Connection getConnection()

No description

Return Value

Connection

private Response buildRedirectToThumbnailResponse(Request $request)

No description

Parameters

Request $request

Return Value

Response

private array|null getThumbnailToGenerate(Connection $database, string|null $searchThumbnailPath = null)

No description

Parameters

Connection $database
string|null $searchThumbnailPath

Return Value

array|null

private bool generateThumbnail(array $thumbnail)

Generate a thumbnail.

Parameters

array $thumbnail

Return Value

bool

Returns true if success, false on failure

private bool attemptBuild(File $file, array $thumbnail)

Try building an unbuilt thumbnail.

Parameters

File $file
array $thumbnail

Return Value

bool

private array getDimensions(array $thumbnail)

Get the dimensions out of a thumbnail array.

Parameters

array $thumbnail

Return Value

array

[ width, height, crop ]

private bool isBuilt(File $file, array $thumbnail)

No description

Parameters

File $file
array $thumbnail

Return Value

bool

private null|StorageLocationInterface storageLocation()

No description

Return Value

null|StorageLocationInterface

private Connection|null tryGetConnection()

No description

Return Value

Connection|null

private markThumbnailAsBuilt(Connection $connection, array $thumbnail, bool $built = true)

Mark a thumbnail as built or not.

Parameters

Connection $connection
array $thumbnail
bool $built

private bool couldBeTheRequestedThumbnail(array $thumbnail, string|null $searchThumbnailPath)

Check if a thumbnail array may be for the requested path.

Parameters

array $thumbnail
string|null $searchThumbnailPath

Return Value

bool

private failBuild(File $file, array $thumbnail)

Mark the build failed.

Parameters

File $file
array $thumbnail