Deletes the file from the configured storage backend.

@param \Cake\Event\Event $event
@return bool
@throws \Burzum\FileStorage\Storage\StorageException
554205
protected function _deleteFile(Event $event) {
		try {
			$this->_beforeDeleteFile($event);
			$entity = $event->getData('entity');
			$path = $this->pathBuilder()->fullPath($entity);

			if ($this->getStorageAdapter($entity->adapter)->delete($path)) {
				$event->result = true;
				$event->setData('path', $path);
				$event->setData('entity', $entity);
				$this->_afterDeleteFile($event);

				return true;
			}
		} catch (\Exception $e) {
			$this->log($e->getMessage(), LogLevel::ERROR, ['scope' => ['storage']]);
			throw new StorageException($e->getMessage(), $e->getCode(), $e);
		}

		return false;
	}
306702
private function deleteFile($file) {
		try {
			if($this->client && $this->client->enabled()) {
				$this->client->delete($file);
			}
		}
		catch(StorageException $ex) {
			Logger::error("Error deleting file '$file'.", ['exception' => $ex->getMessage(), 'Key' => $file]);
		}
	}
804075
protected function handle(Event $event)
    {
        $method = $this->getApplyMethod($event);
        if (!method_exists($this, $method)) {
            return;
        }
        $this->$method($event);
    }
1292842
public function handleEventScriptEvent($event)
    {
        \Cache::forget(Cache::EVENT_SCRIPT_CACHE_PREFIX . $event->script->name);

        return true;
    }
39635
public function handle(DeletingUser $event)
    {
        if ($event->user->isAdmin())
            return false;

        if ($event->user->isForceDeleting())
            $event->user->detachAllRoles(false);

        return true;
    }
705037
public function preRemove(LifecycleEventArgs $event)
    {
        $entity = $event->getEntity();

        if ($entity instanceOf ImageInterface) {
            $this->uploader->remove($entity);
        }
    }
1010904
protected function _checkEvent(Event $event) {
		$className = $this->_getAdapterClassFromConfig($event->getData('entity')['adapter']);
		$classes = $this->_adapterClasses;

		if (!empty($classes) && !in_array($className, $classes)) {
			$message = 'The listener `%s` doesn\'t allow the `%s` adapter class! Probably because it can\'t work with it.';
			throw new StorageException(sprintf(
				$message,
				get_class($this),
				$className
			));
		}

		return $event->getSubject() instanceof Table && $this->_modelFilter($event);
	}
1348087
public function onQuit(Event $event)
    {
        $msg = $event->getMessage();

        if (!isset($msg['nick'])) {
            return;
        }

        $nick = $msg['nick'];

        $this->storage->removeUser($nick);
    }
937675
public function preDelete(DeleteEvent $event)
    {
        /** @var Organization $organization */
        $organization = $event->getObject();
        if ($organization->isDefault()) {
            $event->block();

            // we can also throw an exception
        }

        $keys = $this->om->getRepository(CryptographicKey::class)->findBy(['organization' => $organization]);

        foreach ($keys as $key) {
            $this->crud->delete($key);
        }
    }
196203
public function onDelete(DeleteResourceEvent $event)
    {
        $ds = DIRECTORY_SEPARATOR;
        $scorm = $event->getResource();
        $workspace = $scorm->getResourceNode()->getWorkspace();
        $hashName = $scorm->getHashName();

        $nbScorm = (int) ($this->scormResourceRepo->findNbScormWithSameSource($hashName, $workspace));

        if (1 === $nbScorm) {
            $scormArchiveFile = $this->filesDir.$ds.'scorm'.$ds.$workspace->getUuid().$ds.$hashName;
            $scormResourcesPath = $this->uploadDir.$ds.'scorm'.$ds.$workspace->getUuid().$ds.$hashName;

            if (file_exists($scormArchiveFile)) {
                $event->setFiles([$scormArchiveFile]);
            }
            if (file_exists($scormResourcesPath)) {
                try {
                    $this->deleteFiles($scormResourcesPath);
                } catch (\Exception $e) {
                }
            }
        }
        $this->om->remove($event->getResource());
        $event->stopPropagation();
    }
287508
public function deleteMetadata(EventInterface $event) {
        $request = $event->getRequest();

        $event->getDatabase()->deleteMetadata(
            $request->getUser(),
            $request->getImageIdentifier()
        );

        $event->getDatabase()->setLastModifiedNow(
            $request->getUser(),
            $request->getImageIdentifier()
        );
    }
565990
public function destroy(Event $event)
    {
        $this->authorize('delete', $event);
        $event->deleteUsers($event->users);
        $event->delete();

        return redirect()->route('laralum::events.index')
            ->with('success', __('laralum_events::general.event_deleted', ['id' => $event->id]));
    }
793454
public static function clear(string $event = '') {
		if (empty($event)) {
			self::$events = [];
		} else {
			self::$events[$event] = [];
		}
	}
367541
public function deleted(Events\Deleted $event): bool
    {
        if (config('tenancy.website.auto-delete-tenant-directory')) {
            $stat = $this->filesystem()->deleteDirectory($event->website->uuid);

            if ($stat) {
                $this->emitEvent(
                    new DirectoryDeleted($event->website, $this->filesystem())
                );
            }

            return $stat;
        }

        return true;
    }
1364130
public function removeEvent($event) {
		$result = remove_entity_relationship($event->guid, self::EVENT_CALENDAR_RELATIONSHIP, $this->guid);

		if ($result) {
			// allow events to fire after confirmation that it has been added to the calendar
			elgg_trigger_event('events_api', 'remove_from_calendar', array('event' => $event, 'calendar' => $this));
		}

		return $result;
	}
1099686
public function guestDeleteAction(Event $event)
    {
        $invitation = $this->checkGuestAccess($event);

        $invitation->setStatus(EventInvitation::RESIGN);
        $this->om->flush();

        return new JsonResponse($event->jsonSerialize(), 200);
    }
334570
public function onDelete(DeleteResourceEvent $event)
    {
        $workspaceCode = $event->getResource()
            ->getResourceNode()
            ->getWorkspace()
            ->getCode();
        $pathName = $this->container->getParameter('claroline.param.files_directory') .
            DIRECTORY_SEPARATOR .
            $event->getResource()->getHashName();

        if (file_exists($pathName)) {
            $event->setFiles(array($pathName));
        }

        $event->stopPropagation();
    }