diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitBase.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitBase.php index 6dcbd36..5045eb5 100644 --- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitBase.php +++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitBase.php @@ -21,7 +21,7 @@ protected $operationManager; /** - * Constructs a Drupal\Component\Plugin\ImageToolkitBase object. + * Constructs an ImageToolkitBase object. * * @param array $configuration * A configuration array containing information about the plugin instance. @@ -45,7 +45,7 @@ public function getRequirements() { } /** - * Get a toolkit operation plugin instance. + * Gets a toolkit operation plugin instance. * * @param string $operation * The toolkit operation requested. @@ -66,11 +66,11 @@ public function apply($operation, ImageInterface $image, array $arguments = arra return $this->getToolkitOperation($operation)->apply($image, $arguments); } catch (PluginNotFoundException $e) { - watchdog('image', 'The selected image handling toolkit %toolkit can not process operation %operation.', array('%toolkit' => $this->getPluginId(), '%operation' => $operation), WATCHDOG_ERROR); + \Drupal::logger('image')->error('The selected image handling toolkit %toolkit can not process operation %operation.', array('%toolkit' => $this->getPluginId(), '%operation' => $operation)); return FALSE; } catch (\InvalidArgumentException $e) { - watchdog('image', $e->getMessage(), array(), WATCHDOG_WARNING); + \Drupal::logger('image')->warning($e->getMessage(), array()); return FALSE; } } diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitInterface.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitInterface.php index 0ff2128..04d32f3 100644 --- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitInterface.php +++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitInterface.php @@ -159,7 +159,7 @@ public static function getSupportedExtensions(); * operation, e.g. array('width' => 50, 'height' => 100, * 'upscale' => TRUE). * - * @return mixed + * @return bool * TRUE if the operation was performed successfully, FALSE otherwise. */ public function apply($operation, ImageInterface $image, array $arguments = array()); diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php index 5d3a815..79f9310 100644 --- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php +++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php @@ -8,6 +8,7 @@ namespace Drupal\Core\ImageToolkit; use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException; +use Drupal\Component\Utility\String; use Drupal\Core\Image\ImageInterface; use Drupal\Core\Plugin\PluginBase; @@ -57,19 +58,18 @@ protected function getToolkit() { * Image toolkit operation implementers must implement this method to * "document" their operation, thus also if no arguments are expected. * - * An array whose keys are the names of the arguments (e.g. "width", - * "degrees") and each value is an associative array having the following - * keys: - * - description: A string with the argument description. This is used only - * internally for documentation purposes, so it does not need to be - * translatable. - * - required: (optional) A boolean indicating if this argument should be - * provided or not. Defaults to TRUE. - * - default: (optional) When the argument is set to "required" = FALSE, - * this must be set to a default value. Ignored for "required" = TRUE - * arguments. - * * @return array + * An array whose keys are the names of the arguments (e.g. "width", + * "degrees") and each value is an associative array having the following + * keys: + * - description: A string with the argument description. This is used only + * internally for documentation purposes, so it does not need to be + * translatable. + * - required: (optional) A boolean indicating if this argument should be + * provided or not. Defaults to TRUE. + * - default: (optional) When the argument is set to "required" = FALSE, + * this must be set to a default value. Ignored for "required" = TRUE + * arguments. */ abstract protected function arguments(); @@ -96,7 +96,7 @@ protected function prepareArguments(array $arguments) { if ($argument['required']) { if (!array_key_exists($id, $arguments)) { // If the argument is required throw an exception. - throw new \InvalidArgumentException("Argument '$id' expected by plugin '" . $this->getPluginId() . "' but not passed."); + throw new \InvalidArgumentException(String::format("Argument '!argument' expected by plugin '!plugin' but not passed.", array('!argument' => $id, '!plugin' => $this->getPluginId()))); } } else { @@ -106,7 +106,7 @@ protected function prepareArguments(array $arguments) { if (!array_key_exists('default', $argument)) { // The plugin did not define a default, so throw a plugin exception, // not an invalid argument exception. - throw new InvalidPluginDefinitionException("Default for argument '$id' expected by plugin '" . $this->getPluginId() . "' but not defined."); + throw new InvalidPluginDefinitionException(String::format("Default for argument '!argument' expected by plugin '!plugin' but not defined.", array('!argument' => $id, '!plugin' => $this->getPluginId()))); } // Use the default value if the argument is not passed in. diff --git a/core/modules/image/src/Plugin/ImageEffect/CropImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/CropImageEffect.php index 761e28d..b242d4c 100644 --- a/core/modules/image/src/Plugin/ImageEffect/CropImageEffect.php +++ b/core/modules/image/src/Plugin/ImageEffect/CropImageEffect.php @@ -29,7 +29,7 @@ public function applyEffect(ImageInterface $image) { $y = image_filter_keyword($y, $image->getHeight(), $this->configuration['height']); $data = array('x' => $x, 'y' => $y, 'width' => $this->configuration['width'], 'height' => $this->configuration['height']); if (!$image->apply('crop', $data)) { - watchdog('image', 'Image crop failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()), WATCHDOG_ERROR); + \Drupal::logger('image')->error('Image crop failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight())); return FALSE; } return TRUE; diff --git a/core/modules/image/src/Plugin/ImageEffect/DesaturateImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/DesaturateImageEffect.php index 62311f3..8d323b9 100644 --- a/core/modules/image/src/Plugin/ImageEffect/DesaturateImageEffect.php +++ b/core/modules/image/src/Plugin/ImageEffect/DesaturateImageEffect.php @@ -32,7 +32,7 @@ public function transformDimensions(array &$dimensions) { */ public function applyEffect(ImageInterface $image) { if (!$image->apply('desaturate')) { - watchdog('image', 'Image desaturate failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()), WATCHDOG_ERROR); + \Drupal::logger('image')->error('Image desaturate failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight())); return FALSE; } return TRUE; diff --git a/core/modules/image/src/Plugin/ImageEffect/ResizeImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/ResizeImageEffect.php index 653100b..e39f609 100644 --- a/core/modules/image/src/Plugin/ImageEffect/ResizeImageEffect.php +++ b/core/modules/image/src/Plugin/ImageEffect/ResizeImageEffect.php @@ -27,7 +27,7 @@ class ResizeImageEffect extends ConfigurableImageEffectBase { public function applyEffect(ImageInterface $image) { $data = array('width' => $this->configuration['width'], 'height' => $this->configuration['height']); if (!$image->apply('resize', $data)) { - watchdog('image', 'Image resize failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()), WATCHDOG_ERROR); + \Drupal::logger('image')->error('Image resize failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight())); return FALSE; } return TRUE; diff --git a/core/modules/image/src/Plugin/ImageEffect/RotateImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/RotateImageEffect.php index 5a5e062..6538303 100644 --- a/core/modules/image/src/Plugin/ImageEffect/RotateImageEffect.php +++ b/core/modules/image/src/Plugin/ImageEffect/RotateImageEffect.php @@ -47,7 +47,7 @@ public function applyEffect(ImageInterface $image) { $data = array('degrees' => $this->configuration['degrees'], 'background' => $this->configuration['bgcolor']); if (!$image->apply('rotate', $data)) { - watchdog('image', 'Image rotate failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()), WATCHDOG_ERROR); + \Drupal::logger('image')->error('Image rotate failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight())); return FALSE; } return TRUE; diff --git a/core/modules/image/src/Plugin/ImageEffect/ScaleAndCropImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/ScaleAndCropImageEffect.php index 4aa77f4..ab24c5d 100644 --- a/core/modules/image/src/Plugin/ImageEffect/ScaleAndCropImageEffect.php +++ b/core/modules/image/src/Plugin/ImageEffect/ScaleAndCropImageEffect.php @@ -26,7 +26,7 @@ class ScaleAndCropImageEffect extends ResizeImageEffect { public function applyEffect(ImageInterface $image) { $data = array('width' => $this->configuration['width'], 'height' => $this->configuration['height']); if (!$image->apply('scale_and_crop', $data)) { - watchdog('image', 'Image scale and crop failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()), WATCHDOG_ERROR); + \Drupal::logger('image')->error('Image scale and crop failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight())); return FALSE; } return TRUE; diff --git a/core/modules/image/src/Plugin/ImageEffect/ScaleImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/ScaleImageEffect.php index 53842dd..325c2a9 100644 --- a/core/modules/image/src/Plugin/ImageEffect/ScaleImageEffect.php +++ b/core/modules/image/src/Plugin/ImageEffect/ScaleImageEffect.php @@ -27,7 +27,7 @@ class ScaleImageEffect extends ResizeImageEffect { public function applyEffect(ImageInterface $image) { $data = array('width' => $this->configuration['width'], 'height' => $this->configuration['height'], 'upscale' => $this->configuration['upscale']); if (!$image->apply('scale', $data)) { - watchdog('image', 'Image scale failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()), WATCHDOG_ERROR); + \Drupal::logger('image')->error('Image scale failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight())); return FALSE; } return TRUE; diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Crop.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Crop.php index 7751868..a9b494b 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Crop.php +++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Crop.php @@ -13,7 +13,7 @@ * Defines GD2 Crop operation. * * @ImageToolkitOperation( - * id = "gd.crop", + * id = "gd_crop", * operation = "crop", * label = @Translation("Crop"), * description = @Translation("Crops an image to a rectangle specified by the given dimensions.") diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Desaturate.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Desaturate.php index e2bf45e..cd17f5f 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Desaturate.php +++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Desaturate.php @@ -13,7 +13,7 @@ * Defines GD2 Desaturate operation. * * @ImageToolkitOperation( - * id = "gd.desaturate", + * id = "gd_desaturate", * operation = "desaturate", * label = @Translation("Desaturate"), * description = @Translation("Converts an image to grayscale.") @@ -35,7 +35,7 @@ protected function arguments() { protected function execute(ImageInterface $image, array $arguments) { // PHP installations using non-bundled GD do not have imagefilter. if (!function_exists('imagefilter')) { - watchdog('image', 'The image %file could not be desaturated because the imagefilter() function is not available in this PHP installation.', array('%file' => $image->getSource())); + \Drupal::logger('image')->notice('The image %file could not be desaturated because the imagefilter() function is not available in this PHP installation.', array('%file' => $image->getSource())); return FALSE; } diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Resize.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Resize.php index 8b164b0..699e7bf 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Resize.php +++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Resize.php @@ -13,7 +13,7 @@ * Defines GD2 resize operation. * * @ImageToolkitOperation( - * id = "gd.resize", + * id = "gd_resize", * operation = "resize", * label = @Translation("Resize"), * description = @Translation("Resizes an image to the given dimensions (ignoring aspect ratio).") diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Rotate.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Rotate.php index 5679d65..f9b51d1 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Rotate.php +++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Rotate.php @@ -13,7 +13,7 @@ * Defines GD2 rotate operation. * * @ImageToolkitOperation( - * id = "gd.rotate", + * id = "gd_rotate", * operation = "rotate", * label = @Translation("Rotate"), * description = @Translation("Rotates an image by the given number of degrees.") @@ -43,7 +43,7 @@ protected function arguments() { protected function execute(ImageInterface $image, array $arguments) { // PHP installations using non-bundled GD do not have imagerotate. if (!function_exists('imagerotate')) { - watchdog('image', 'The image %file could not be rotated because the imagerotate() function is not available in this PHP installation.', array('%file' => $image->getSource())); + \Drupal::logger('image')->notice('The image %file could not be rotated because the imagerotate() function is not available in this PHP installation.', array('%file' => $image->getSource())); return FALSE; } diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Scale.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Scale.php index 4a70429..4d7f7f3 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Scale.php +++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Scale.php @@ -13,7 +13,7 @@ * Defines GD2 Scale operation. * * @ImageToolkitOperation( - * id = "gd.scale", + * id = "gd_scale", * operation = "scale", * label = @Translation("Scale"), * description = @Translation("Scales an image while maintaining aspect ratio. The resulting image can be smaller for one or both target dimensions.") diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php index 13304a4..14df6b9 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php +++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php @@ -13,7 +13,7 @@ * Defines GD2 Scale and crop operation. * * @ImageToolkitOperation( - * id = "gd.scale_and_crop", + * id = "gd_scale_and_crop", * operation = "scale_and_crop", * label = @Translation("Scale and crop"), * description = @Translation("Scales an image to the exact width and height given. This plugin achieves the target aspect ratio by cropping the original image equally on both sides, or equally on the top and bottom. This function is useful to create uniform sized avatars from larger images.")