class ImageAPIOptimizeHookImplementations in Image Optimize (or ImageAPI Optimize) 8.2
Same name and namespace in other branches
- 8.3 src/ImageAPIOptimizeHookImplementations.php \Drupal\imageapi_optimize\ImageAPIOptimizeHookImplementations
- 4.x src/ImageAPIOptimizeHookImplementations.php \Drupal\imageapi_optimize\ImageAPIOptimizeHookImplementations
Hook implementations for the Image Optimize module.
Hierarchy
- class \Drupal\imageapi_optimize\ImageAPIOptimizeHookImplementations uses StringTranslationTrait
Expanded class hierarchy of ImageAPIOptimizeHookImplementations
1 string reference to 'ImageAPIOptimizeHookImplementations'
1 service uses ImageAPIOptimizeHookImplementations
File
- src/
ImageAPIOptimizeHookImplementations.php, line 12
Namespace
Drupal\imageapi_optimizeView source
class ImageAPIOptimizeHookImplementations {
use StringTranslationTrait;
/**
* Constructs a new ImageAPIOptimizeHookImplementations object.
*
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The stream translation service.
*/
public function __construct(TranslationInterface $string_translation) {
$this->stringTranslation = $string_translation;
}
/**
* Implements hook_entity_type_alter().
*/
public function entity_type_alter(array &$entity_types) {
/** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
if (isset($entity_types['image_style'])) {
$image_style = $entity_types['image_style'];
$image_style
->setClass('Drupal\\imageapi_optimize\\Entity\\ImageStyleWithPipeline');
$image_style
->setHandlerClass('list_builder', 'Drupal\\imageapi_optimize\\ImageStyleWithPipelineListBuilder');
$config_export = $image_style
->get('config_export');
$config_export[] = 'pipeline';
$image_style
->set('config_export', $config_export);
}
}
/**
* Implements hook_form_image_style_edit_form_alter().
*/
public function form_image_style_edit_form_alter(&$form, FormStateInterface $form_state, $form_id) {
$entity = $form_state
->getFormObject()
->getEntity();
$form['pipeline'] = [
'#type' => 'select',
'#title' => $this
->t('Image Optimize Pipeline'),
'#options' => imageapi_optimize_pipeline_options(),
'#default_value' => $entity
->getPipeline(),
'#description' => $this
->t('Optionally select an Image Optimization pipeline which will be applied after all effects in this image style.'),
'#weight' => 10,
];
}
/**
* Implements hook_config_schema_info_alter().
*/
public function config_schema_info_alter(&$definitions) {
if (isset($definitions['image.style.*'])) {
$definitions['image.style.*']['mapping']['pipeline']['type'] = 'string';
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ImageAPIOptimizeHookImplementations:: |
public | function | Implements hook_config_schema_info_alter(). | |
ImageAPIOptimizeHookImplementations:: |
public | function | Implements hook_entity_type_alter(). | |
ImageAPIOptimizeHookImplementations:: |
public | function | Implements hook_form_image_style_edit_form_alter(). | |
ImageAPIOptimizeHookImplementations:: |
public | function | Constructs a new ImageAPIOptimizeHookImplementations object. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |