Drupal 8  8.0.2
TestToolkit Class Reference
Inheritance diagram for TestToolkit:

Public Member Functions

 __construct (array $configuration, $plugin_id, array $plugin_definition, ImageToolkitOperationManagerInterface $operation_manager, LoggerInterface $logger, ConfigFactoryInterface $config_factory, StateInterface $state)
 
 buildConfigurationForm (array $form, FormStateInterface $form_state)
 
 validateConfigurationForm (array &$form, FormStateInterface $form_state)
 
 submitConfigurationForm (array &$form, FormStateInterface $form_state)
 
 isValid ()
 
 parseFile ()
 
 save ($destination)
 
 getWidth ()
 
 getHeight ()
 
 getType ()
 
 setType ($type)
 
 getMimeType ()
 
 apply ($operation, array $arguments=array())
 
- Public Member Functions inherited from ImageToolkitBase
 __construct (array $configuration, $plugin_id, array $plugin_definition, ImageToolkitOperationManagerInterface $operation_manager, LoggerInterface $logger, ConfigFactoryInterface $config_factory)
 
 validateConfigurationForm (array &$form, FormStateInterface $form_state)
 
 setSource ($source)
 
 getSource ()
 
 getRequirements ()
 
 apply ($operation, array $arguments=array())
 
- Public Member Functions inherited from PluginInspectionInterface
 getPluginId ()
 
 getPluginDefinition ()
 

Static Public Member Functions

static create (ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition)
 
static isAvailable ()
 
static getSupportedExtensions ()
 

Protected Member Functions

 logCall ($op, $args)
 
- Protected Member Functions inherited from ImageToolkitBase
 getToolkitOperation ($operation)
 

Static Protected Member Functions

static supportedTypes ()
 

Protected Attributes

 $state
 
 $type
 
 $width
 
 $height
 
- Protected Attributes inherited from ImageToolkitBase
 $configFactory
 
 $source = ''
 
 $operationManager
 
 $logger
 

Detailed Description

Defines a Test toolkit for image manipulation within Drupal.

( id = "test", title = ("A dummy toolkit that works") )

Constructor & Destructor Documentation

__construct ( array  $configuration,
  $plugin_id,
array  $plugin_definition,
ImageToolkitOperationManagerInterface  $operation_manager,
LoggerInterface  $logger,
ConfigFactoryInterface  $config_factory,
StateInterface  $state 
)

Constructs a TestToolkit object.

Parameters
array$configurationA configuration array containing information about the plugin instance.
string$plugin_idThe plugin_id for the plugin instance.
array$plugin_definitionThe plugin implementation definition.
\Drupal\Core\ImageToolkit\ImageToolkitOperationManagerInterface$operation_managerThe toolkit operation manager.
\Psr\Log\LoggerInterface$loggerA logger instance.
\Drupal\Core\Config\ConfigFactoryInterface$config_factoryThe config factory.
\Drupal\Core\State\StateInterface$stateThe state key value store.

References Drupal\state().

Here is the call graph for this function:

Member Function Documentation

apply (   $operation,
array  $arguments = array() 
)

{Applies a toolkit operation to an image.

Parameters
string$operationThe toolkit operation to be processed.
array$argumentsAn associative array of arguments to be passed to the toolkit operation, e.g. array('width' => 50, 'height' => 100, 'upscale' => TRUE).
Returns
bool TRUE if the operation was performed successfully, FALSE otherwise.
}

Implements ImageToolkitInterface.

References TestToolkit\logCall().

Here is the call graph for this function:

buildConfigurationForm ( array  $form,
FormStateInterface  $form_state 
)

{Form constructor.Plugin forms are embedded in other forms. In order to know where the plugin form is located in the parent form, #parents and #array_parents must be known, but these are not available during the initial build phase. In order to have these properties available when building the plugin form's elements, let this method return a form element that has a #process callback and build the rest of the form in the callback. By the time the callback is executed, the element's #parents and #array_parents properties will have been set by the form API. For more documentation on #parents and #array_parents, see .

Parameters
array$formAn associative array containing the initial structure of the plugin form.
\Drupal\Core\Form\FormStateInterface$form_stateThe current state of the complete form.
Returns
array The form structure.
}

Implements PluginFormInterface.

References Drupal\configFactory(), TestToolkit\logCall(), and t().

Here is the call graph for this function:

static create ( ContainerInterface  $container,
array  $configuration,
  $plugin_id,
  $plugin_definition 
)
static

{Creates an instance of the plugin.

Parameters
\Symfony\Component\DependencyInjection\ContainerInterface$containerThe container to pull out services used in the plugin.
array$configurationA configuration array containing information about the plugin instance.
string$plugin_idThe plugin ID for the plugin instance.
mixed$plugin_definitionThe plugin implementation definition.
Returns
static Returns an instance of this plugin.
}

Implements ContainerFactoryPluginInterface.

getHeight ( )

{Returns the height of the image.

Returns
int|null The height of the image, or NULL if the image is invalid.
}

Implements ImageToolkitInterface.

getMimeType ( )

{Returns the MIME type of the image file.

Returns
string The MIME type of the image file, or an empty string if the image is invalid.
}

Implements ImageToolkitInterface.

References TestToolkit\getType().

Here is the call graph for this function:

static getSupportedExtensions ( )
static

{Returns a list of image file extensions supported by the toolkit.

Returns
array An array of supported image file extensions (e.g. png/jpeg/gif).
}

Implements ImageToolkitInterface.

References Unicode\strtolower().

Here is the call graph for this function:

getType ( )

Returns the type of the image.

Returns
int The image type represented by a PHP IMAGETYPE_* constant (e.g. IMAGETYPE_JPEG).

Referenced by TestToolkit\getMimeType().

Here is the caller graph for this function:

getWidth ( )

{Returns the width of the image.

Returns
int|null The width of the image, or NULL if the image is invalid.
}

Implements ImageToolkitInterface.

static isAvailable ( )
static

{Verifies that the Image Toolkit is set up correctly.

Returns
bool TRUE if the toolkit is available on this machine, FALSE otherwise.
}

Implements ImageToolkitInterface.

isValid ( )

{Checks if the image is valid.

Returns
bool TRUE if the image toolkit is currently handling a valid image, FALSE otherwise.
}

Implements ImageToolkitInterface.

logCall (   $op,
  $args 
)
protected

Stores the values passed to a toolkit call.

Parameters
string$opOne of the toolkit methods 'parseFile', 'save', 'settings', or 'apply'.
array$argsValues passed to hook.
See Also
::imageTestReset()
::imageTestGetAllCalls()

References Drupal\state().

Referenced by TestToolkit\apply(), TestToolkit\buildConfigurationForm(), TestToolkit\parseFile(), and TestToolkit\save().

Here is the call graph for this function:

Here is the caller graph for this function:

parseFile ( )

{Determines if a file contains a valid image.Drupal supports GIF, JPG and PNG file formats when used with the GD toolkit, and may support others, depending on which toolkits are installed.

Returns
bool TRUE if the file could be found and is an image, FALSE otherwise.
}

Implements ImageToolkitInterface.

References ImageToolkitBase\getSource(), TestToolkit\logCall(), and TestToolkit\setType().

Here is the call graph for this function:

save (   $destination)

{Writes an image resource to a destination file.

Parameters
string$destinationA string file URI or path where the image should be saved.
Returns
bool TRUE on success, FALSE on failure.
}

Implements ImageToolkitInterface.

References TestToolkit\logCall().

Referenced by TestToolkit\submitConfigurationForm().

Here is the call graph for this function:

Here is the caller graph for this function:

setType (   $type)

Sets the PHP type of the image.

Parameters
int$typeThe image type represented by a PHP IMAGETYPE_* constant (e.g. IMAGETYPE_JPEG).
Returns
$this

Referenced by TestToolkit\parseFile().

Here is the caller graph for this function:

submitConfigurationForm ( array &  $form,
FormStateInterface  $form_state 
)

{Form submission handler.

Parameters
array$formAn associative array containing the structure of the plugin form as built by static::buildConfigurationForm().
\Drupal\Core\Form\FormStateInterface$form_stateThe current state of the complete form.
}

Implements PluginFormInterface.

References Drupal\configFactory(), FormStateInterface\getValue(), and TestToolkit\save().

Here is the call graph for this function:

static supportedTypes ( )
staticprotected

Returns a list of image types supported by the toolkit.

Returns
array An array of available image types. An image type is represented by a PHP IMAGETYPE_* constant (e.g. IMAGETYPE_JPEG, IMAGETYPE_PNG, etc.).
validateConfigurationForm ( array &  $form,
FormStateInterface  $form_state 
)

{Form validation handler.

Parameters
array$formAn associative array containing the structure of the plugin form as built by static::buildConfigurationForm().
\Drupal\Core\Form\FormStateInterface$form_stateThe current state of the complete form.
}

Implements PluginFormInterface.

References FormStateInterface\getValue(), FormStateInterface\setErrorByName(), and t().

Here is the call graph for this function:


The documentation for this class was generated from the following file: