public function testCanDeleteAllTransformations() { $variations = [['width' => 770, 'height' => 564], ['width' => 385, 'height' => 282], ['width' => 192, 'height' => 140]]; foreach ($variations as $variation) { $this->assertTrue($this->adapter->storeImageVariationMetadata('key', 'id', $variation['width'], $variation['height'])); } $this->assertTrue($this->adapter->deleteImageVariations('key', 'id')); $this->assertSame(null, $this->adapter->getBestMatch('key', 'id', 100)); }
/** * Delete all image variations attached to an image * * If any of the delete operations fail Imbo will trigger an error * * @param EventInterface $event The current event */ public function deleteVariations(EventInterface $event) { $request = $event->getRequest(); $publicKey = $request->getPublicKey(); $imageIdentifier = $request->getImageIdentifier(); try { $this->database->deleteImageVariations($publicKey, $imageIdentifier); } catch (DatabaseException $e) { trigger_error(sprintf('Could not delete image variation metadata for %s (%s)', $publicKey, $imageIdentifier), E_USER_WARNING); } try { $this->storage->deleteImageVariations($publicKey, $imageIdentifier); } catch (StorageException $e) { trigger_error(sprintf('Could not delete image variations from storage for %s (%s)', $publicKey, $imageIdentifier), E_USER_WARNING); } }