abstract class AbstractParamsProcessor (View source)

Base class to implement image service parameter compatibility.

This class was introduced along with the TwicPics image service to implement a basic compatibility layer with Imgix-type parameters. There are a few instances in the Twill and Twill Image [1] source code where parameters were hardcoded, such as:

  • w
  • h
  • fm
  • q
  • fit=crop

This was adopted internally as the minimum set of parameters for which Twill image services need to provide compatibility.

[1] https://github.com/area17/twill-image

Constants

COMPATIBLE_PARAMS

Properties

protected $params
protected $width
protected $height
protected $format
protected $quality
protected $fit

Methods

array
finalizeParams()

Abstract method to be implemented in concrete params processor classes.

array
process(array $params)

Receives the original params array and calls the appropriate handler method for each param. Custom handlers can be defined by following this naming convention: handleParamNAME, where NAME is the name of the param.

void
handleParam(string $key, mixed $value)

The generic param handler. Known parameter values will be extracted into the corresponding properties as defined in COMPATIBLE_PARAMS. Unknown params will remain untouched.

Details

abstract array finalizeParams()

Abstract method to be implemented in concrete params processor classes.

This method is called after all parameters have been processed and must return a finalized params array to generate the image URL.

Return Value

array

array process(array $params)

Receives the original params array and calls the appropriate handler method for each param. Custom handlers can be defined by following this naming convention: handleParamNAME, where NAME is the name of the param.

Parameters

array $params

Return Value

array

protected void handleParam(string $key, mixed $value)

The generic param handler. Known parameter values will be extracted into the corresponding properties as defined in COMPATIBLE_PARAMS. Unknown params will remain untouched.

Parameters

string $key
mixed $value

Return Value

void