[ 'prefix' => 'u', 'longPrefix' => 'uri', 'required' => true, 'description' => 'Delivery Execution Uri aka. Result Identifier Uri' ], ]; } protected function provideDescription() { return 'The script deletes all result cache for the specified delivery execution/result'; } protected function provideUsage() { return [ 'prefix' => 'h', 'longPrefix' => 'help', ]; } protected function run() { try { /** @var ServiceProxy $serviceProxy */ $serviceProxy = $this->getServiceLocator()->get(ServiceProxy::SERVICE_ID); /** @var \core_kernel_classes_Resource $resource */ $deliveryExecution = $serviceProxy->getDeliveryExecution($this->getOption('deliveryExecutionUri')); /** @var ResultsService $resultsService */ $resultsService = $this->getServiceManager()->get(ResultServiceWrapper::SERVICE_ID)->getService(); if (is_null($resultsService->getCache())) { throw new \RuntimeException('No result cache has been configured in persistence, so there is nothing to delete.'); } $deliveryExecutionIdentifier = $deliveryExecution->getIdentifier(); if ($resultsService->deleteCacheFor($deliveryExecutionIdentifier)) { $report = Report::createSuccess("Cache has been successfully deleted for entry '${deliveryExecutionIdentifier}'."); } else { throw new \RuntimeException("No cache has been deleted for entry '${deliveryExecutionIdentifier}'."); } } catch (\Exception $e) { $report = Report::createFailure($e->getMessage()); } return $report; } }