diff --git a/imageapi_optimize.api.php b/imageapi_optimize.api.php new file mode 100644 index 0000000000000000000000000000000000000000..a848e97bd2e58fa13c2db63dbe370ff5246e3155 --- /dev/null +++ b/imageapi_optimize.api.php @@ -0,0 +1,25 @@ +<?php + +/** + * @file + * Hooks related to image optimize pipelines and processors. + */ + +/** + * @addtogroup hooks + * @{ + */ + +/** + * Alter the information provided in \Drupal\imageapi_optimize\Annotation\ImageAPIOptimizeProcessor. + * + * @param $processors + * The array of image optimize processors, keyed on the machine-readable processor name. + */ +function imageapi_optimize_processor_info(&$processors) { + +} + +/** + * @} End of "addtogroup hooks". + */ diff --git a/src/Annotation/ImageAPIOptimizeProcessor.php b/src/Annotation/ImageAPIOptimizeProcessor.php index 3a1b920fba9c1a6662b02339ed8897460e39875f..1c6e70d51c26319676719064f943c256c8856013 100644 --- a/src/Annotation/ImageAPIOptimizeProcessor.php +++ b/src/Annotation/ImageAPIOptimizeProcessor.php @@ -5,7 +5,7 @@ namespace Drupal\imageapi_optimize\Annotation; use Drupal\Component\Annotation\Plugin; /** - * Defines an image effect annotation object. + * Defines an image optimize processor annotation object. * * Plugin Namespace: Plugin\ImageEffect * @@ -33,7 +33,7 @@ class ImageAPIOptimizeProcessor extends Plugin { public $id; /** - * The human-readable name of the image effect. + * The human-readable name of the image optimize processor. * * @ingroup plugin_translatable * @@ -42,9 +42,9 @@ class ImageAPIOptimizeProcessor extends Plugin { public $label; /** - * A brief description of the image effect. + * A brief description of the image optimize processor. * - * This will be shown when adding or configuring this image effect. + * This will be shown when adding or configuring this image optimize processor. * * @ingroup plugin_translatable * diff --git a/src/ConfigurableImageAPIOptimizeProcessorBase.php b/src/ConfigurableImageAPIOptimizeProcessorBase.php index e532de9d3bf41b84989b206831d8cc45d46b44ae..73882b59866d4ef11d8d0e6bab9d1ad383d56079 100644 --- a/src/ConfigurableImageAPIOptimizeProcessorBase.php +++ b/src/ConfigurableImageAPIOptimizeProcessorBase.php @@ -5,7 +5,7 @@ namespace Drupal\imageapi_optimize; use Drupal\Core\Form\FormStateInterface; /** - * Provides a base class for configurable image effects. + * Provides a base class for configurable image optimize processors. * * @see \Drupal\imageapi_optimize\Annotation\ImageEffect * @see \Drupal\imageapi_optimize\ConfigurableImageEffectInterface diff --git a/src/ConfigurableImageAPIOptimizeProcessorInterface.php b/src/ConfigurableImageAPIOptimizeProcessorInterface.php index 0559c57e837d0ac758068cbb5736531b54eb0526..2a79336172ee042b56b3a797e55596655d1b30a2 100644 --- a/src/ConfigurableImageAPIOptimizeProcessorInterface.php +++ b/src/ConfigurableImageAPIOptimizeProcessorInterface.php @@ -5,7 +5,7 @@ namespace Drupal\imageapi_optimize; use Drupal\Core\Plugin\PluginFormInterface; /** - * Defines the interface for configurable image effects. + * Defines the interface for configurable image optimize processors. * * @see \Drupal\imageapi_optimize\Annotation\ImageEffect * @see \Drupal\imageapi_optimize\ConfigurableImageEffectBase diff --git a/src/Entity/ImageAPIOptimizePipeline.php b/src/Entity/ImageAPIOptimizePipeline.php index 50ecf4943aad1b2ae6fd59d596300f10e3d96ee0..80c23d08f03ddfff0c5de5897480d64dce56c8c5 100644 --- a/src/Entity/ImageAPIOptimizePipeline.php +++ b/src/Entity/ImageAPIOptimizePipeline.php @@ -18,7 +18,7 @@ use Drupal\Core\StreamWrapper\StreamWrapperInterface; use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; use Drupal\Core\Entity\Entity\EntityViewDisplay; /** - * Defines an image style configuration entity. + * Defines an image optimize pipeline configuration entity. * * @ConfigEntityType( * id = "imageapi_optimize_pipeline", @@ -55,28 +55,28 @@ use Drupal\Core\Entity\Entity\EntityViewDisplay; class ImageAPIOptimizePipeline extends ConfigEntityBase implements ImageAPIOptimizePipelineInterface, EntityWithPluginCollectionInterface { /** - * The name of the image style. + * The name of the image optimize pipeline. * * @var string */ protected $name; /** - * The image style label. + * The image optimize pipeline label. * * @var string */ protected $label; /** - * The array of image effects for this image style. + * The array of image optimize processors for this image optimize pipeline. * * @var array */ protected $processors = array(); /** - * Holds the collection of image effects that are used by this image style. + * Holds the collection of image optimize processors that are used by this image optimize pipeline. * * @var \Drupal\imageapi_optimize\ImageAPIOptimizeProcessorPluginCollection */ @@ -97,7 +97,7 @@ class ImageAPIOptimizePipeline extends ConfigEntityBase implements ImageAPIOptim if ($update) { if (!empty($this->original) && $this->id() !== $this->original->id()) { - // The old image style name needs flushing after a rename. + // The old image optimize pipeline name needs flushing after a rename. $this->original->flush(); // Update field settings if necessary. if (!$this->isSyncing()) { @@ -128,14 +128,14 @@ class ImageAPIOptimizePipeline extends ConfigEntityBase implements ImageAPIOptim } /** - * Update field settings if the image style name is changed. + * Update field settings if the image optimize pipeline name is changed. * * @param \Drupal\imageapi_optimize\ImageAPIOptimizePipelineInterface $style - * The image style. + * The image optimize pipeline. */ protected static function replaceImageAPIOptimizePipeline(ImageAPIOptimizePipelineInterface $style) { if ($style->id() != $style->getOriginalId()) { - // Loop through all image styles looking for usages. + // Loop through all image optimize pipelines looking for usages. } } @@ -145,7 +145,7 @@ class ImageAPIOptimizePipeline extends ConfigEntityBase implements ImageAPIOptim */ public function flush() { - // Get all image styles and if they use this pipeline, flush it. + // Get all image optimize pipelines and if they use this pipeline, flush it. $style_storage = $this->entityTypeManager()->getStorage('image_style'); foreach ($style_storage->loadMultiple() as $style) { /** @var ImageStyleWithPipeline $style */ @@ -248,10 +248,10 @@ class ImageAPIOptimizePipeline extends ConfigEntityBase implements ImageAPIOptim } /** - * Returns the image effect plugin manager. + * Returns the image optimize processor plugin manager. * * @return \Drupal\Component\Plugin\PluginManagerInterface - * The image effect plugin manager. + * The image optimize processor plugin manager. */ protected function getImageAPIOptimizeProcessorPluginManager() { return \Drupal::service('plugin.manager.imageapi_optimize.processor'); diff --git a/src/Form/ImageAPIOptimizePipelineAddForm.php b/src/Form/ImageAPIOptimizePipelineAddForm.php index 63b8272ff01c91104d754280f7fd1767f5fbf8c7..1e01ce36b2d3d9981559a967e816a970883d206b 100644 --- a/src/Form/ImageAPIOptimizePipelineAddForm.php +++ b/src/Form/ImageAPIOptimizePipelineAddForm.php @@ -5,7 +5,7 @@ namespace Drupal\imageapi_optimize\Form; use Drupal\Core\Form\FormStateInterface; /** - * Controller for image style addition forms. + * Controller for image optimize pipeline addition forms. */ class ImageAPIOptimizePipelineAddForm extends ImageAPIOptimizePipelineFormBase { diff --git a/src/Form/ImageAPIOptimizePipelineDeleteForm.php b/src/Form/ImageAPIOptimizePipelineDeleteForm.php index 6d24105ba1a59f6bafde8e1288c71c2340842acc..1fb9c252d1a71d09fadaca01383f41453b0d11d6 100644 --- a/src/Form/ImageAPIOptimizePipelineDeleteForm.php +++ b/src/Form/ImageAPIOptimizePipelineDeleteForm.php @@ -6,7 +6,7 @@ use Drupal\Core\Entity\EntityDeleteForm; use Drupal\Core\Form\FormStateInterface; /** - * Creates a form to delete an image style. + * Creates a form to delete an image optimize pipeline. */ class ImageAPIOptimizePipelineDeleteForm extends EntityDeleteForm { @@ -57,7 +57,7 @@ class ImageAPIOptimizePipelineDeleteForm extends EntityDeleteForm { * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { - // Save a selected replacement in the image style storage. It will be used + // Save a selected replacement in the image optimize pipeline storage. It will be used // later, in the same request, when resolving dependencies. if ($replacement = $form_state->getValue('replacement')) { /** @var \Drupal\imageapi_optimize\ImageAPIOptimizePipelineStorageInterface $storage */ @@ -68,7 +68,7 @@ class ImageAPIOptimizePipelineDeleteForm extends EntityDeleteForm { } /** - * Returns a list of image style replacement options. + * Returns a list of image optimize pipeline replacement options. * * @return array * An option list suitable for the form select '#options'. diff --git a/src/Form/ImageAPIOptimizePipelineEditForm.php b/src/Form/ImageAPIOptimizePipelineEditForm.php index 46508ba8b857bf70a9b7f801feee60a93a3472a7..ceccf49abea69c4d398958ca20621e43ef483e07 100644 --- a/src/Form/ImageAPIOptimizePipelineEditForm.php +++ b/src/Form/ImageAPIOptimizePipelineEditForm.php @@ -10,12 +10,12 @@ use Drupal\imageapi_optimize\ImageAPIOptimizeProcessorManager; use Symfony\Component\DependencyInjection\ContainerInterface; /** - * Controller for image style edit form. + * Controller for image optimize pipeline edit form. */ class ImageAPIOptimizePipelineEditForm extends ImageAPIOptimizePipelineFormBase { /** - * The image effect manager service. + * The image optimize processor manager service. * * @var \Drupal\imageapi_optimize\ImageAPIOptimizeProcessorManager */ @@ -27,7 +27,7 @@ class ImageAPIOptimizePipelineEditForm extends ImageAPIOptimizePipelineFormBase * @param \Drupal\Core\Entity\EntityStorageInterface $imageapi_optimize_pipeline_storage * The storage. * @param \Drupal\imageapi_optimize\ImageAPIOptimizeProcessorManager $imageapi_optimize_processor_manager - * The image effect manager service. + * The image optimize processor manager service. */ public function __construct(EntityStorageInterface $imageapi_optimize_pipeline_storage, ImageAPIOptimizeProcessorManager $imageapi_optimize_processor_manager) { parent::__construct($imageapi_optimize_pipeline_storage); @@ -53,7 +53,7 @@ class ImageAPIOptimizePipelineEditForm extends ImageAPIOptimizePipelineFormBase $form['#tree'] = TRUE; $form['#attached']['library'][] = 'imageapi_optimize/admin'; - // Build the list of existing image processors for this image style. + // Build the list of existing image processors for this image optimize pipeline. $form['processors'] = array( '#type' => 'table', '#header' => array( @@ -180,7 +180,7 @@ class ImageAPIOptimizePipelineEditForm extends ImageAPIOptimizePipelineFormBase } /** - * Validate handler for image effect. + * Validate handler for image optimize processor. */ public function processorValidate($form, FormStateInterface $form_state) { if (!$form_state->getValue('new')) { @@ -189,7 +189,7 @@ class ImageAPIOptimizePipelineEditForm extends ImageAPIOptimizePipelineFormBase } /** - * Submit handler for image effect. + * Submit handler for image optimize processor. */ public function processorSave($form, FormStateInterface $form_state) { $this->save($form, $form_state); @@ -228,7 +228,7 @@ class ImageAPIOptimizePipelineEditForm extends ImageAPIOptimizePipelineFormBase */ public function submitForm(array &$form, FormStateInterface $form_state) { - // Update image effect weights. + // Update image optimize processor weights. if (!$form_state->isValueEmpty('processors')) { $this->updateProcessorWeights($form_state->getValue('processors')); } @@ -255,7 +255,7 @@ class ImageAPIOptimizePipelineEditForm extends ImageAPIOptimizePipelineFormBase } /** - * Updates image effect weights. + * Updates image optimize processor weights. * * @param array $processors * Associative array with effects having effect uuid as keys and array diff --git a/src/Form/ImageAPIOptimizePipelineFlushForm.php b/src/Form/ImageAPIOptimizePipelineFlushForm.php index 28825de60ba76b56331141fb3bb9a4d15f968ee1..7ded366da0a723cac405d259a0ad5a045c361f08 100644 --- a/src/Form/ImageAPIOptimizePipelineFlushForm.php +++ b/src/Form/ImageAPIOptimizePipelineFlushForm.php @@ -6,7 +6,7 @@ use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Form\FormStateInterface; /** - * Form controller for image style flush. + * Form controller for image optimize pipeline flush. */ class ImageAPIOptimizePipelineFlushForm extends EntityConfirmFormBase { diff --git a/src/Form/ImageAPIOptimizePipelineFormBase.php b/src/Form/ImageAPIOptimizePipelineFormBase.php index 3c9baa56dbd2a5a7cc72e0116e4376f10aa13c69..f466c33a825c7661e12e429e0050ae0a9a418ced 100644 --- a/src/Form/ImageAPIOptimizePipelineFormBase.php +++ b/src/Form/ImageAPIOptimizePipelineFormBase.php @@ -8,7 +8,7 @@ use Drupal\Core\Form\FormStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** - * Base form for image style add and edit forms. + * Base form for image optimize pipeline add and edit forms. */ abstract class ImageAPIOptimizePipelineFormBase extends EntityForm { @@ -20,17 +20,17 @@ abstract class ImageAPIOptimizePipelineFormBase extends EntityForm { protected $entity; /** - * The image style entity storage. + * The image optimize pipeline entity storage. * * @var \Drupal\Core\Entity\EntityStorageInterface */ protected $imageapiOptimizePipelineStorage; /** - * Constructs a base class for image style add and edit forms. + * Constructs a base class for image optimize pipeline add and edit forms. * * @param \Drupal\Core\Entity\EntityStorageInterface $imageapi_optimize_pipeline_storage - * The image style entity storage. + * The image optimize pipeline entity storage. */ public function __construct(EntityStorageInterface $imageapi_optimize_pipeline_storage) { $this->imageapiOptimizePipelineStorage = $imageapi_optimize_pipeline_storage; diff --git a/src/Form/ImageAPIOptimizeProcessorAddForm.php b/src/Form/ImageAPIOptimizeProcessorAddForm.php index 1ed2f3cd0cb391bbe552ffb134a770be963ce968..43ab886b3c7b886cb39808198b01fb441dc807a4 100644 --- a/src/Form/ImageAPIOptimizeProcessorAddForm.php +++ b/src/Form/ImageAPIOptimizeProcessorAddForm.php @@ -8,12 +8,12 @@ use Drupal\imageapi_optimize\ImageAPIOptimizePipelineInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** - * Provides an add form for image effects. + * Provides an add form for image optimize processors. */ class ImageAPIOptimizeProcessorAddForm extends ImageAPIOptimizeProcessorFormBase { /** - * The image effect manager. + * The image optimize processor manager. * * @var \Drupal\imageapi_optimize\ImageAPIOptimizeProcessorManager */ @@ -23,7 +23,7 @@ class ImageAPIOptimizeProcessorAddForm extends ImageAPIOptimizeProcessorFormBase * Constructs a new ImageAPIOptimizeProcessorAddForm. * * @param \Drupal\imageapi_optimize\ImageAPIOptimizeProcessorManager $effect_manager - * The image effect manager. + * The image optimize processor manager. */ public function __construct(ImageAPIOptimizeProcessorManager $effect_manager) { $this->processorManager = $effect_manager; diff --git a/src/Form/ImageAPIOptimizeProcessorDeleteForm.php b/src/Form/ImageAPIOptimizeProcessorDeleteForm.php index 22117611bd3db838036fef82fa719168c4fcbdff..27f8e5d27a1148cd9684721bdc2e64562171e158 100644 --- a/src/Form/ImageAPIOptimizeProcessorDeleteForm.php +++ b/src/Form/ImageAPIOptimizeProcessorDeleteForm.php @@ -7,19 +7,19 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\imageapi_optimize\ImageAPIOptimizePipelineInterface; /** - * Form for deleting an image effect. + * Form for deleting an image optimize processor. */ class ImageAPIOptimizeProcessorDeleteForm extends ConfirmFormBase { /** - * The image style containing the image effect to be deleted. + * The image optimize pipeline containing the image optimize processor to be deleted. * * @var \Drupal\imageapi_optimize\ImageAPIOptimizePipelineInterface */ protected $imageAPIOptimizePipeline; /** - * The image effect to be deleted. + * The image optimize processor to be deleted. * * @var \Drupal\imageapi_optimize\ImageAPIOptimizeProcessorInterface */ diff --git a/src/Form/ImageAPIOptimizeProcessorEditForm.php b/src/Form/ImageAPIOptimizeProcessorEditForm.php index 9f85b9e114aa89f651896b6d94d40cbed107e106..c69fa97e5aa8dbaf3ca7fe97e754415796f2da38 100644 --- a/src/Form/ImageAPIOptimizeProcessorEditForm.php +++ b/src/Form/ImageAPIOptimizeProcessorEditForm.php @@ -6,7 +6,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\imageapi_optimize\ImageAPIOptimizePipelineInterface; /** - * Provides an edit form for image effects. + * Provides an edit form for image optimize processors. */ class ImageAPIOptimizeProcessorEditForm extends ImageAPIOptimizeProcessorFormBase { diff --git a/src/Form/ImageAPIOptimizeProcessorFormBase.php b/src/Form/ImageAPIOptimizeProcessorFormBase.php index 90e3a589ae037d8d7372a5cd3bbede99dcf7ae0f..cf759a7c0e824a3decef477c9215049a33ed4e9a 100644 --- a/src/Form/ImageAPIOptimizeProcessorFormBase.php +++ b/src/Form/ImageAPIOptimizeProcessorFormBase.php @@ -11,19 +11,19 @@ use Drupal\Component\Plugin\Exception\PluginNotFoundException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** - * Provides a base form for image effects. + * Provides a base form for image optimize processors. */ abstract class ImageAPIOptimizeProcessorFormBase extends FormBase { /** - * The image style. + * The image optimize pipeline. * * @var \Drupal\imageapi_optimize\ImageAPIOptimizePipelineInterface */ protected $imageAPIOptimizePipeline; /** - * The image effect. + * The image optimize processor. * * @var \Drupal\imageapi_optimize\ImageAPIOptimizeProcessorInterface|\Drupal\imageapi_optimize\ConfigurableImageAPIOptimizeProcessorInterface */ @@ -40,9 +40,9 @@ abstract class ImageAPIOptimizeProcessorFormBase extends FormBase { * {@inheritdoc} * * @param \Drupal\imageapi_optimize\ImageAPIOptimizePipelineInterface $imageapi_optimize_pipeline - * The image style. + * The image optimize pipeline. * @param string $imageapi_optimize_processor - * The image effect ID. + * The image optimize processor ID. * * @return array * The form structure. @@ -78,7 +78,7 @@ abstract class ImageAPIOptimizeProcessorFormBase extends FormBase { $form['data'] = $this->imageAPIOptimizeProcessor->buildConfigurationForm($form['data'], $subform_state); $form['data']['#tree'] = TRUE; - // Check the URL for a weight, then the image effect, otherwise use default. + // Check the URL for a weight, then the image optimize processor, otherwise use default. $form['weight'] = array( '#type' => 'hidden', '#value' => $request->query->has('weight') ? (int) $request->query->get('weight') : $this->imageAPIOptimizeProcessor->getWeight(), @@ -102,7 +102,7 @@ abstract class ImageAPIOptimizeProcessorFormBase extends FormBase { * {@inheritdoc} */ public function validateForm(array &$form, FormStateInterface $form_state) { - // The image effect configuration is stored in the 'data' key in the form, + // The image optimize processor configuration is stored in the 'data' key in the form, // pass that through for validation. $this->imageAPIOptimizeProcessor->validateConfigurationForm($form['data'], SubformState::createForSubform($form['data'], $form, $form_state)); } @@ -113,7 +113,7 @@ abstract class ImageAPIOptimizeProcessorFormBase extends FormBase { public function submitForm(array &$form, FormStateInterface $form_state) { $form_state->cleanValues(); - // The image effect configuration is stored in the 'data' key in the form, + // The image optimize processor configuration is stored in the 'data' key in the form, // pass that through for submission. $this->imageAPIOptimizeProcessor->submitConfigurationForm($form['data'], SubformState::createForSubform($form['data'], $form, $form_state)); @@ -128,13 +128,13 @@ abstract class ImageAPIOptimizeProcessorFormBase extends FormBase { } /** - * Converts an image effect ID into an object. + * Converts an image optimize processor ID into an object. * * @param string $imageapi_optimize_processor - * The image effect ID. + * The image optimize processor ID. * * @return \Drupal\imageapi_optimize\ImageAPIOptimizeProcessorInterface - * The image effect object. + * The image optimize processor object. */ abstract protected function prepareImageAPIOptimizeProcessor($imageapi_optimize_processor); diff --git a/src/ImageAPIOptimizePipelineInterface.php b/src/ImageAPIOptimizePipelineInterface.php index b3bbbbb9e79bfc519d3da28b184d3a7b2c15a933..6be7dcf307226b7badc026f6f29f650b4851bdf2 100644 --- a/src/ImageAPIOptimizePipelineInterface.php +++ b/src/ImageAPIOptimizePipelineInterface.php @@ -5,7 +5,7 @@ namespace Drupal\imageapi_optimize; use Drupal\Core\Config\Entity\ConfigEntityInterface; /** - * Provides an interface defining an image style entity. + * Provides an interface defining an image optimize pipeline entity. */ interface ImageAPIOptimizePipelineInterface extends ConfigEntityInterface { @@ -13,7 +13,7 @@ interface ImageAPIOptimizePipelineInterface extends ConfigEntityInterface { * Returns the replacement ID. * * @return string|null - * The replacement image style ID or NULL if no replacement has been + * The replacement image optimize pipeline ID or NULL if no replacement has been * selected. * * @deprecated in Drupal 8.0.x, will be removed before Drupal 9.0.x. Use @@ -24,18 +24,18 @@ interface ImageAPIOptimizePipelineInterface extends ConfigEntityInterface { public function getReplacementID(); /** - * Returns the image style. + * Returns the image optimize pipeline. * * @return string - * The name of the image style. + * The name of the image optimize pipeline. */ public function getName(); /** - * Sets the name of the image style. + * Sets the name of the image optimize pipeline. * * @param string $name - * The name of the image style. + * The name of the image optimize pipeline. * * @return \Drupal\imageapi_optimize\ImageStyleInterface * The class instance this method is called on. @@ -43,40 +43,40 @@ interface ImageAPIOptimizePipelineInterface extends ConfigEntityInterface { public function setName($name); /** - * Returns a specific image effect. + * Returns a specific image optimize processor. * * @param string $effect - * The image effect ID. + * The image optimize processor ID. * * @return \Drupal\imageapi_optimize\ImageAPIOptimizeProcessorInterface - * The image effect object. + * The image optimize processor object. */ public function getProcessor($processor); /** - * Returns the image effects for this style. + * Returns the image optimize processors for this style. * * @return \Drupal\imageapi_optimize\ImageAPIOptimizeProcessorPluginCollection|\Drupal\imageapi_optimize\ImageAPIOptimizeProcessorInterface[] - * The image effect plugin collection. + * The image optimize processor plugin collection. */ public function getProcessors(); /** - * Saves an image effect for this style. + * Saves an image optimize processor for this style. * * @param array $configuration - * An array of image effect configuration. + * An array of image optimize processor configuration. * * @return string - * The image effect ID. + * The image optimize processor ID. */ public function addProcessor(array $configuration); /** - * Deletes an image effect from this style. + * Deletes an image optimize processor from this style. * * @param \Drupal\imageapi_optimize\ImageAPIOptimizeProcessorInterface $effect - * The image effect object. + * The image optimize processor object. * * @return $this */ @@ -90,9 +90,9 @@ interface ImageAPIOptimizePipelineInterface extends ConfigEntityInterface { public function flush(); /** - * Creates a new image derivative based on this image style. + * Creates a new image derivative based on this image optimize pipeline. * - * Generates an image derivative applying all image effects and saving the + * Generates an image derivative applying all image optimize processors and saving the * resulting image. * * @param string $image_uri diff --git a/src/ImageAPIOptimizePipelineListBuilder.php b/src/ImageAPIOptimizePipelineListBuilder.php index 669c5c3a807c11176fb0078c3a0361f15d31c498..6da0076d4e01090c2d0a0730e7f9b7136eee42cb 100644 --- a/src/ImageAPIOptimizePipelineListBuilder.php +++ b/src/ImageAPIOptimizePipelineListBuilder.php @@ -7,7 +7,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Url; /** - * Defines a class to build a listing of image style entities. + * Defines a class to build a listing of image optimize pipeline entities. * * @see \Drupal\imageapi_optimize\Entity\ImageStyle */ diff --git a/src/ImageAPIOptimizePipelineStorage.php b/src/ImageAPIOptimizePipelineStorage.php index 02a78c9f2893dfb5ad7afb03c5416809a48d2a4d..8f43a6ff0debd64a74e1cf07602a263bfdd28449 100644 --- a/src/ImageAPIOptimizePipelineStorage.php +++ b/src/ImageAPIOptimizePipelineStorage.php @@ -5,15 +5,15 @@ namespace Drupal\imageapi_optimize; use Drupal\Core\Config\Entity\ConfigEntityStorage; /** - * Storage controller class for "image style" configuration entities. + * Storage controller class for "image optimize pipeline" configuration entities. */ class ImageAPIOptimizePipelineStorage extends ConfigEntityStorage implements ImageAPIOptimizePipelineStorageInterface { /** - * Image style replacement memory storage. + * Image optimize pipeline replacement memory storage. * * This value is not stored in the backend. It's used during the deletion of - * an image style to save the replacement image style in the same request. The + * an image optimize pipeline to save the replacement image optimize pipeline in the same request. The * value is used later, when resolving dependencies. * * @var string[] diff --git a/src/ImageAPIOptimizePipelineStorageInterface.php b/src/ImageAPIOptimizePipelineStorageInterface.php index 0075831fe76efdb5b966430cf56b0fbc5a448392..ac707ccceb911ca92deeb2db267909475d065950 100644 --- a/src/ImageAPIOptimizePipelineStorageInterface.php +++ b/src/ImageAPIOptimizePipelineStorageInterface.php @@ -8,30 +8,30 @@ namespace Drupal\imageapi_optimize; interface ImageAPIOptimizePipelineStorageInterface { /** - * Stores a replacement ID for an image style being deleted. + * Stores a replacement ID for an image optimize pipeline being deleted. * * The method stores a replacement style to be used by the configuration - * dependency system when a image style is deleted. The replacement style is + * dependency system when a image optimize pipeline is deleted. The replacement style is * replacing the deleted style in other configuration entities that are - * depending on the image style being deleted. + * depending on the image optimize pipeline being deleted. * * @param string $name - * The ID of the image style to be deleted. + * The ID of the image optimize pipeline to be deleted. * @param string $replacement - * The ID of the image style used as replacement. + * The ID of the image optimize pipeline used as replacement. */ public function setReplacementId($name, $replacement); /** - * Retrieves the replacement ID of a deleted image style. + * Retrieves the replacement ID of a deleted image optimize pipeline. * * The method is retrieving the value stored by ::setReplacementId(). * * @param string $name - * The ID of the image style to be replaced. + * The ID of the image optimize pipeline to be replaced. * * @return string|null - * The ID of the image style used as replacement, if there's any, or NULL. + * The ID of the image optimize pipeline used as replacement, if there's any, or NULL. * * @see \Drupal\imageapi_optimize\ImageStyleStorageInterface::setReplacementId() */ @@ -43,7 +43,7 @@ interface ImageAPIOptimizePipelineStorageInterface { * The method clears the value previously stored with ::setReplacementId(). * * @param string $name - * The ID of the image style to be replaced. + * The ID of the image optimize pipeline to be replaced. * * @see \Drupal\imageapi_optimize\ImageStyleStorageInterface::setReplacementId() */ diff --git a/src/ImageAPIOptimizeProcessorBase.php b/src/ImageAPIOptimizeProcessorBase.php index fe628a40909933a2c9420840bcbd4f6880eb1805..eda9040a6414109e6dee859dfc27c88dd06b0df6 100644 --- a/src/ImageAPIOptimizeProcessorBase.php +++ b/src/ImageAPIOptimizeProcessorBase.php @@ -9,7 +9,7 @@ use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** - * Provides a base class for image effects. + * Provides a base class for image optimize processors. * * @see \Drupal\imageapi_optimize\Annotation\ImageEffect * @see \Drupal\imageapi_optimize\ImageEffectInterface @@ -21,14 +21,14 @@ use Symfony\Component\DependencyInjection\ContainerInterface; abstract class ImageAPIOptimizeProcessorBase extends PluginBase implements ImageAPIOptimizeProcessorInterface, ContainerFactoryPluginInterface { /** - * The image effect ID. + * The image optimize processor ID. * * @var string */ protected $uuid; /** - * The weight of the image effect. + * The weight of the image optimize processor. * * @var int|string */ diff --git a/src/ImageAPIOptimizeProcessorBinaryBase.php b/src/ImageAPIOptimizeProcessorBinaryBase.php index ed633e620ef784a39b95f1073ca20ece9c312964..9bebbe8288a71eb0c6cb5e235bb3b4fe4be8b518 100644 --- a/src/ImageAPIOptimizeProcessorBinaryBase.php +++ b/src/ImageAPIOptimizeProcessorBinaryBase.php @@ -10,7 +10,7 @@ use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** - * Uses the resmush.it webservice to optimize an image. + * Base class for image optimizations that run local binaries. */ abstract class ImageAPIOptimizeProcessorBinaryBase extends ConfigurableImageAPIOptimizeProcessorBase { @@ -91,6 +91,17 @@ abstract class ImageAPIOptimizeProcessorBinaryBase extends ConfigurableImageAPIO $this->configuration['manual_executable_path'] = $form_state->getValue('manual_executable_path'); } + /** + * Search the local system for the given executable binary. + * + * @param null $executable + * The name of the executable binary to find on the local system. If not + * specified the default executeable name for this class will be used. + * + * @return string|false + * The path to the binary on the local system, or FALSE if it could not be + * located. + */ protected function findExecutablePath($executable = NULL) { if (is_null($executable)) { $executable = $this->executableName(); @@ -101,8 +112,22 @@ abstract class ImageAPIOptimizeProcessorBinaryBase extends ConfigurableImageAPIO if ($return_var == 0) { return $path; } + return FALSE; } + /** + * Execute a shell command on the local system. + * + * @param $command + * The command to execute. + * @param $options + * An array of options for the command. This will not be escaped before executing. + * @param $arguments + * An array of arguments for the command. These will be escaped. + * + * @return bool + * Returns TRUE if the command completed successfully, FALSE otherwise. + */ protected function execShellCommand($command, $options, $arguments) { $output = array(); $return_val = 0; diff --git a/src/ImageAPIOptimizeProcessorInterface.php b/src/ImageAPIOptimizeProcessorInterface.php index fb921e5deba8d1b0afa3268577a9fa69974ea2d7..52911683c3a792e0d5b1ac2b7d17ed556ecb3eeb 100644 --- a/src/ImageAPIOptimizeProcessorInterface.php +++ b/src/ImageAPIOptimizeProcessorInterface.php @@ -7,19 +7,19 @@ use Drupal\Component\Plugin\PluginInspectionInterface; use Drupal\imageapi_optimize\ImageInterface; /** - * Defines the interface for image effects. + * Defines the interface for image optimize processors. * - * @see \Drupal\imageapi_optimize\Annotation\ImageEffect - * @see \Drupal\imageapi_optimize\ImageEffectBase - * @see \Drupal\imageapi_optimize\ConfigurableImageEffectInterface - * @see \Drupal\imageapi_optimize\ConfigurableImageEffectBase - * @see \Drupal\imageapi_optimize\ImageEffectManager + * @see \Drupal\imageapi_optimize\Annotation\ImageAPIOptimizeProcessor + * @see \Drupal\imageapi_optimize\ImageAPIOptimizeProcessorBase + * @see \Drupal\imageapi_optimize\ConfigurableImageAPIOptimizeProcessorInterface + * @see \Drupal\imageapi_optimize\ConfigurableImageAPIOptimizeProcessorBase + * @see \Drupal\imageapi_optimize\ImageAPIOptimizeProcessorManager * @see plugin_api */ interface ImageAPIOptimizeProcessorInterface extends PluginInspectionInterface, ConfigurablePluginInterface { /** - * Returns a render array summarizing the configuration of the image effect. + * Returns a render array summarizing the configuration of the image optimize processor. * * @return array * A render array. @@ -27,51 +27,51 @@ interface ImageAPIOptimizeProcessorInterface extends PluginInspectionInterface, public function getSummary(); /** - * Returns the image effect label. + * Returns the image optimize processor label. * * @return string - * The image effect label. + * The image optimize processor label. */ public function label(); /** - * Returns the unique ID representing the image effect. + * Returns the unique ID representing the image optimize processor. * * @return string - * The image effect ID. + * The image optimize processor ID. */ public function getUuid(); /** - * Returns the weight of the image effect. + * Returns the weight of the image optimize processor. * * @return int|string - * Either the integer weight of the image effect, or an empty string. + * Either the integer weight of the image optimize processor, or an empty string. */ public function getWeight(); /** - * Sets the weight for this image effect. + * Sets the weight for this image optimize processor. * * @param int $weight - * The weight for this image effect. + * The weight for this image optimize processor. * * @return $this */ public function setWeight($weight); /** - * Creates a new image derivative based on this image style. + * Apply this image optimize processor to the given image. * - * Generates an image derivative applying all image effects and saving the - * resulting image. + * Image processors should modify the file in-place or overwrite the file on + * disk with an optimized version. * * @param string $image_uri * Original image file URI. * * @return bool - * TRUE if an image derivative was generated, or FALSE if the image - * derivative could not be generated. + * TRUE if an optimized image was generated, or FALSE if the image + * could not be optimized. */ public function applyToImage($image_uri); diff --git a/src/ImageAPIOptimizeProcessorManager.php b/src/ImageAPIOptimizeProcessorManager.php index d08a61fa0c88a9edfe2b6716451810c14b1e9605..06867556325ed66ed3e468548de719642cb88cc5 100644 --- a/src/ImageAPIOptimizeProcessorManager.php +++ b/src/ImageAPIOptimizeProcessorManager.php @@ -7,14 +7,14 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Plugin\DefaultPluginManager; /** - * Manages image effect plugins. + * Manages image optimize processor plugins. * - * @see hook_image_effect_info_alter() - * @see \Drupal\imageapi_optimize\Annotation\ImageEffect - * @see \Drupal\imageapi_optimize\ConfigurableImageEffectInterface - * @see \Drupal\imageapi_optimize\ConfigurableImageEffectBase - * @see \Drupal\imageapi_optimize\ImageEffectInterface - * @see \Drupal\imageapi_optimize\ImageEffectBase + * @see hook_imageapi_optimize_processor_info_alter() + * @see \Drupal\imageapi_optimize\Annotation\ImageAPIOptimizeProcessor + * @see \Drupal\imageapi_optimize\ConfigurableImageAPIOptimizeProcessorInterface + * @see \Drupal\imageapi_optimize\ConfigurableImageAPIOptimizeProcessorBase + * @see \Drupal\imageapi_optimize\ImageAPIOptimizeProcessorInterface + * @see \Drupal\imageapi_optimize\ImageAPIOptimizeProcessorBase * @see plugin_api */ class ImageAPIOptimizeProcessorManager extends DefaultPluginManager { diff --git a/src/ImageAPIOptimizeProcessorPluginCollection.php b/src/ImageAPIOptimizeProcessorPluginCollection.php index 7e8486cdfb57a6ac31a4607d95ccc3a37dd37ac7..11443b71741651683af326bb9ebce67736bc902b 100644 --- a/src/ImageAPIOptimizeProcessorPluginCollection.php +++ b/src/ImageAPIOptimizeProcessorPluginCollection.php @@ -5,7 +5,7 @@ namespace Drupal\imageapi_optimize; use Drupal\Core\Plugin\DefaultLazyPluginCollection; /** - * A collection of image effects. + * A collection of image optimize processors. */ class ImageAPIOptimizeProcessorPluginCollection extends DefaultLazyPluginCollection { diff --git a/src/ImageStyleWithPipelineListBuilder.php b/src/ImageStyleWithPipelineListBuilder.php index 0d45198f945e41f7a5800dcfe6cfb6ecfefa111e..2d30860ada2b62d4f50f8b161ff09aaabe55ba8f 100644 --- a/src/ImageStyleWithPipelineListBuilder.php +++ b/src/ImageStyleWithPipelineListBuilder.php @@ -6,7 +6,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\image\ImageStyleListBuilder; /** - * Defines a class to build a listing of image style entities. + * Defines a class to build a listing of image optimize pipeline entities. * * Adds a pipeline column to the table. *