Chris@0: operationManager = $operation_manager; Chris@0: $this->logger = $logger; Chris@0: $this->configFactory = $config_factory; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {} Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function setSource($source) { Chris@0: // If a previous image has been loaded, there is no way to know if the Chris@0: // toolkit implementation needs to perform any additional actions like Chris@0: // freeing memory. Therefore, the source image cannot be changed once set. Chris@0: if ($this->source) { Chris@0: throw new \BadMethodCallException(__METHOD__ . '() may only be called once'); Chris@0: } Chris@0: $this->source = $source; Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getSource() { Chris@0: return $this->source; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getRequirements() { Chris@0: return []; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Gets a toolkit operation plugin instance. Chris@0: * Chris@0: * @param string $operation Chris@0: * The toolkit operation requested. Chris@0: * Chris@0: * @return \Drupal\Core\ImageToolkit\ImageToolkitOperationInterface Chris@0: * An instance of the requested toolkit operation plugin. Chris@0: */ Chris@0: protected function getToolkitOperation($operation) { Chris@0: return $this->operationManager->getToolkitOperation($this, $operation); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function apply($operation, array $arguments = []) { Chris@0: try { Chris@0: // Get the plugin to use for the operation and apply the operation. Chris@0: return $this->getToolkitOperation($operation)->apply($arguments); Chris@0: } Chris@0: catch (PluginNotFoundException $e) { Chris@0: $this->logger->error("The selected image handling toolkit '@toolkit' can not process operation '@operation'.", ['@toolkit' => $this->getPluginId(), '@operation' => $operation]); Chris@0: return FALSE; Chris@0: } Chris@0: catch (\InvalidArgumentException $e) { Chris@0: $this->logger->warning($e->getMessage(), []); Chris@0: return FALSE; Chris@0: } Chris@0: } Chris@0: Chris@0: }