Removes versions for a given image record

@param Event $Event
@return void
499641
protected function _removeVersions(Event $Event) {
		if ($this->_checkEvent($Event)) {
			$data = $Event->getData();

			$Storage = $data['storage'];
			$record = $data['record'];
			foreach ($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();
		}
	}
1040977
protected function _modifyBelongsTo(Event $event)
    {
        $belongsTo = $event->subject->viewVars['associations']['belongsTo'];

        foreach ($belongsTo as $i => $association) {
            if ($association['alias'] !== 'Versions' || $association['foreignKey'] !== 'version_id') {
                continue;
            }

            unset($belongsTo[$i]);
        }

        return $belongsTo;
    }
120259
public function deleteImage(EventInterface $event) {
        $event->getManager()->trigger('db.image.delete');
        $event->getManager()->trigger('storage.image.delete');

        $model = new Model\ArrayModel();
        $model->setData([
            'imageIdentifier' => $event->getRequest()->getImageIdentifier(),
        ]);

        $event->getResponse()->setModel($model);
    }
1345350
public function delete(EventInterface $event) {
        $event->getManager()->trigger('db.metadata.delete');
        $event->getResponse()->setModel(new Model\Metadata());
    }
154428
function clearEventHandlers($event = null)
	{
		if (!empty($event)) {
			$this->_events[$event] = array();
		}
		else {
			$this->_events = array();
		}
	}
967474
public function preRemove(User $user, LifecycleEventArgs $event)
    {
        $oldAvatarImage = $user->getAvatarImage();
        if (!empty($oldAvatarImage)) {
            $this->userService->deleteAvatar($oldAvatarImage);
        }
    }
70076
public static function clearCache(Event $event)
    {
        // to avoid errors due to the encrypted container forcibly clean the cache directory
        $dir = self::getRootDir().'cache/prod';
        if (is_dir($dir)) {
            (new Filesystem())->remove($dir);
        }

        self::executeCommand('cache:clear --no-warmup --env=prod --no-debug', $event->getIO());
        self::executeCommand('cache:clear --no-warmup --env=dev --no-debug', $event->getIO());
    }
1115723
public static function onFlushElementFile(Event $event)
    {
        $revision = $event->getTarget();
        $content = $revision->getContent();

        if (!($content instanceof ElementFile) || !is_file($content->path)) {
            return;
        }

        $application = $event->getApplication();
        $em = $application->getEntityManager();
        $uow = $em->getUnitOfWork();

        if ($uow->isScheduledForDelete($content)) {
            return;
        }

        $fileRepository = $em->getRepository('BackBee\ClassContent\Element\File');
        $fileRepository->setDirectories($application);

        $fileRepository->commitFile($content);

        $moveFrom = $content->path;
        File::resolveFilepath($moveFrom, null, array('base_dir' => $application->getMediaDir()));

        if (file_exists($moveFrom)) {
            $content->setParam('stat', json_encode(stat($moveFrom)));

            if ($content instanceof ElementImage) {
                list($width, $height) = getimagesize($moveFrom);

                $content->setParam('width', $width);
                $content->setParam('height', $height);
            }
        }

        $uow->recomputeSingleEntityChangeSet($em->getClassMetadata('BackBee\ClassContent\Revision'), $revision);
    }
333127
public void removeSnapshots() {
        VersionList versionToRemove = new VersionList();

        // collect Versions to be removed
        for (Version ver : this) {
            if (ver.isSnapshot()) {
                versionToRemove.add(ver);
            }
        }

        // remove them
        this.removeAll(versionToRemove);
    }
650524
public function clearGlobalEventHandlers($event = null)
    {
        if (!empty($event)) {
            $this->globalEvents[$event] = [];
        } else {
            $this->globalEvents = [];
        }
    }
249326
public function onRemoved(RemovedEvent $event)
    {
        if ($event->getPackage()->getType() == self::PLUGIN_TYPE) {
            $plugin = $this->rep->find($event->getPackage()->getName());

            if ($plugin) {
                $this->em->remove($plugin);
                $this->em->flush();
            }
        }
    }
1079039
public function record(Event $event)
    {
        $eventUuid = $event->uuid();
        $this->recordedEvents[(string) $eventUuid] = $event;
    }
127278
public function beforeDispatch(Event $event)
    {
        /* @var \Cake\Http\ServerRequest $request */
        $request = $event->getData('request');
        $locale = Locale::acceptFromHttp($request->getHeaderLine('Accept-Language'));

        if (!$locale || (!empty($this->_locales) && !in_array($locale, $this->_locales))) {
            return;
        }

        I18n::setLocale($locale);
    }
318002
protected function _removeImage($record, $options) {
		$Event = new Event('ImageVersion.removeVersion', $this->Table, [
			'entity' => $record,
			'operations' => $options
		]);
		EventManager::instance()->dispatch($Event);
	}
1118485
public function removeAll()
    {
        $portableElements = $this->getAll();
        foreach ($portableElements as $identifier => $versions) {
            $this->removeAllVersions($identifier);
        }
    }
821996
public function remove(EventInterface $event)
    {
        foreach ($this->events as $key => $internalEvent) {
            if ($event->getUid() === $internalEvent->getUid()) {
                unset($this->events[$key]);
            }
        }
    }
1324053
public function removeImageVersions(EntityInterface $entity, array $versions, array $options = []) {
		$this->_checkImageVersions($entity->model, $versions);

		$result = [];
		foreach ($versions as $version) {
			$hash = $this->getImageVersionHash($entity->model, $version);
			$path = $this->pathBuilder()->fullPath($entity, ['fileSuffix' => '.' . $hash]);
			$result[$version] = [
				'status' => 'success',
				'hash' => $hash,
				'path' => $path
			];
			try {
				$this->getStorageAdapter($entity->adapter)->delete($path);
			} catch (\Exception $e) {
				$result[$version]['status'] = 'error';
				$result[$version]['error'] = $e->getMessage();
			}
		}

		return $result;
	}