/** * Serializes and then hashes an array of operations that are applied to an image * * @param array $operations * @return string */ public static function hashOperations($operations) { return StorageUtils::hashOperations($operations); }
/** * testHashOperations * * @return void */ public function testHashOperations() { $result = StorageUtils::hashOperations(array('mode' => 'inbound', 'width' => 80, 'height' => 80)); $this->assertEquals($result, '8c70933e'); }
/** * Removes versions for a given image record * * @param Event $Event * @return void */ protected function _removeVersions(Event $Event) { if ($this->_checkEvent($Event)) { $Storage = $Event->data['storage']; $record = $Event->data['record']; foreach ($Event->data['operations'] as $version => $operations) { $hash = StorageUtils::hashOperations($operations); $string = $this->_buildPath($record, true, $hash); if ($this->adapterClass === 'AmazonS3' || $this->adapterClass === 'AwsS3') { $string = str_replace('\\', '/', $string); } try { if ($Storage->has($string)) { $Storage->delete($string); } } catch (\Exception $e) { $this->log($e->getMessage()); } } $Event->stopPropagation(); } }