Delete a resource within a project.

@param string $project  The slug for the project the resource is part of
@param string $resource The resource slug within the project

@return ResponseInterface
765304
public function deleteResource(string $project, string $resource): ResponseInterface
    {
        return $this->client->sendRequest($this->createRequest('DELETE', $this->createUri("/api/2/project/$project/resource/$resource")));
    }
230558
protected function setupDeleteReference($resource)
    {
        foreach ($resource->settings['actions']['DeleteReference']['uris'] as $property => $uri) {
            $this->setupDelete($resource, $uri, $property);
        }
    }
1269672
public function deleteBulkAction(Request $request, $class)
    {
        /** @var Workspace[] $workspaces */
        $workspaces = parent::decodeIdsString($request, Workspace::class);
        $errors = [];

        foreach ($workspaces as $workspace) {
            $notDeletableResources = $this->resourceManager->getNotDeletableResourcesByWorkspace($workspace);

            if (count($notDeletableResources)) {
                $errors[$workspace->getUuid()] = $this->translator->trans(
                    'workspace_not_deletable_resources_error_message',
                    ['%workspaceName%' => $workspace->getName()],
                    'platform'
                );
            }
        }
        if (empty($errors)) {
            parent::deleteBulkAction($request, Workspace::class);

            return new JsonResponse('success', 200);
        } else {
            $validIds = [];
            $ids = $request->query->get('ids');

            foreach ($ids as $id) {
                if (!isset($errors[$id])) {
                    $validIds[] = $id;
                }
            }
            if (count($validIds) > 0) {
                $request->query->set('ids', $validIds);
                parent::deleteBulkAction($request, 'Claroline\CoreBundle\Entity\Workspace\Workspace');
            }

            return new JsonResponse(['errors' => $errors], 422);
        }
    }
724496
public static function deletePermissionsForResource($resources)
    {
        $resources = is_array($resources) ? $resources : [$resources];
        $result    = 0;

        foreach ($resources as $resource) {
            foreach (static::allPermissionsFor($resource) as $name) {
                PermissionProxy::where(['name' => $name])->delete();
                $result++;
            }
        }

        app(PermissionRegistrar::class)->forgetCachedPermissions();

        return $result;
    }
1115571
public function deleteShortUrl(EventInterface $event) {
        $database = $event->getDatabase();
        $request = $event->getRequest();
        $user = $request->getUser();
        $imageIdentifier = $request->getImageIdentifier();
        $shortUrlId = $request->getRoute()->get('shortUrlId');

        if (!$params = $database->getShortUrlParams($shortUrlId)) {
            throw new ResourceException('ShortURL not found', 404);
        }

        if ($params['user'] !== $user || $params['imageIdentifier'] !== $imageIdentifier) {
            throw new ResourceException('ShortURL not found', 404);
        }

        $database->deleteShortUrls(
            $user,
            $imageIdentifier,
            $shortUrlId
        );

        $model = new ArrayModel();
        $model->setData([
            'id' => $shortUrlId,
        ]);

        $event->getResponse()->setModel($model);
    }
1043608
def delete_project(self, resource):
        
        self.project_service.set_auth(self._token_project)
        self.project_service.delete(resource)
417036
public function delete($projectStatus, $params = array(), $options = array())
    {
        $path = sprintf("/project_statuses/%s", $projectStatus);
        return $this->client->delete($path, $params, $options);
    }
863771
public function delete(Resource $resource)
    {
        $data = $resource->toArray();

        $client = $this->getRepository()->findOneBy(array('id' => $data['id']));
        if (!$client) {
            $errorMessage = $this->translator->trans('error.client_not_found', array('%id%' => $data['id']));
            throw new NotFoundHttpException($errorMessage);
        }

        $this->entityManager->remove($client);
    }
92703
public function deleteRule(EventInterface $event) {
        $acl = $event->getAccessControl();

        if (!($acl instanceof MutableAdapterInterface)) {
            throw new ResourceException('Access control adapter is immutable', 405);
        }

        $request = $event->getRequest();
        $publicKey = $request->getRoute()->get('publickey');
        $accessRuleId = $request->getRoute()->get('accessRuleId');

        $keyExists = $acl->publicKeyExists($publicKey);

        if (!$keyExists) {
            throw new RuntimeException('Public key not found', 404);
        }

        $accessRule = $acl->getAccessRule($publicKey, $accessRuleId);

        if (!$accessRule) {
            throw new RuntimeException('Access rule not found', 404);
        }

        $acl->deleteAccessRule($publicKey, $accessRuleId);
    }
1109194
public function deleteProject(int $projectId): bool
    {
        if ($projectId <= 0 || ! $projectId || ! filter_var($projectId, FILTER_VALIDATE_INT)) {
            return false;
        }

        $result = $this->delete('projects/' . $projectId);

        return 204 === $result->getStatusCode();
    }
1120978
public function delete($id) {
        $object = $this->getContainer()->dataObject();
        $object->setName($id);

        /** @type \Guzzle\Http\Message\Response $response */
        $response = $object->delete();

        return $response->isSuccessful();
    }
993535
public function destroy($id)
    {
        $find = $this->findResourceCallable($id);

        $delete = $this->deleteResourceCallable($id);

        $resource = new DeleteResource($this->serializer);

        return $this->addHeaders($resource->get($id, get_class($this->getDataModel()), $find, $delete));
    }
891855
public function updateProject(Project $project)
    {
        $stmt = $this->db->prepare('SELECT COUNT(*) FROM project WHERE slug = :slug');
        $stmt->bindValue(':slug', $project->getSlug(), \PDO::PARAM_STR);

        if (false === $stmt->execute()) {
            // @codeCoverageIgnoreStart
            throw new \RuntimeException(sprintf('Unable to verify existence of project "%s".', $project->getName()));
            // @codeCoverageIgnoreEnd
        }

        if ($stmt->fetchColumn(0)) {
            $stmt = $this->db->prepare('UPDATE project SET slug = :slug, name = :name, repository = :repository, branch = :branch, command = :command, url_pattern = :url_pattern WHERE slug = :slug');
        } else {
            $stmt = $this->db->prepare('INSERT INTO project (slug, name, repository, branch, command, url_pattern) VALUES (:slug, :name, :repository, :branch, :command, :url_pattern)');
        }

        $stmt->bindValue(':slug', $project->getSlug(), \PDO::PARAM_STR);
        $stmt->bindValue(':name', $project->getName(), \PDO::PARAM_STR);
        $stmt->bindValue(':repository', $project->getRepository(), \PDO::PARAM_STR);
        $stmt->bindValue(':branch', $project->getBranch(), \PDO::PARAM_STR);
        $stmt->bindValue(':command', $project->getCommand(), \PDO::PARAM_STR);
        $stmt->bindValue(':url_pattern', $project->getUrlPattern(), \PDO::PARAM_STR);

        if (false === $stmt->execute()) {
            // @codeCoverageIgnoreStart
            throw new \RuntimeException(sprintf('Unable to save project "%s".', $project->getName()));
            // @codeCoverageIgnoreEnd
        }

        // related commits
        $stmt = $this->db->prepare('SELECT sha, author, date, build_date, message, status, output FROM `commit` WHERE slug = :slug ORDER BY `status` = "building" DESC, build_date DESC LIMIT 100');
        $stmt->bindValue(':slug', $project->getSlug(), \PDO::PARAM_STR);

        if (false === $stmt->execute()) {
            // @codeCoverageIgnoreStart
            throw new \RuntimeException(sprintf('Unable to get latest commit for project "%s".', $project->getName()));
            // @codeCoverageIgnoreEnd
        }

        $commits = array();
        while ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) {
            $commits[] = $this->createCommit($project, $result);
        }

        $project->setCommits($commits);

        // project building?
        $stmt = $this->db->prepare('SELECT COUNT(*) AS count FROM `commit` WHERE slug = :slug AND status = "building"');
        $stmt->bindValue(':slug', $project->getSlug(), \PDO::PARAM_STR);

        $building = false;
        if ($stmt->execute() and intval($stmt->fetchColumn(0))) {
            $building = true;
        }

        $project->setBuilding($building);
    }
394649
public function destroy(Request $request, $key)
    {
        $this->getFormRequestInstance();

        $model = $this->findFirstByKey($key);

        if (!$model) {
            if ($request->wantsJson()) {
                return $this->validNotFoundJsonResponse();
            }
            abort(404);
        }

        DB::beginTransaction();

        try {
            $this->repository->delete($model);
        } catch (\Exception $e) {
            DB::rollback();

            $message = $this->destroyFailedMessage($key, $e->getMessage());
            throw new ResourceControllerException($message);
        }

        DB::commit();

        $message = $this->destroySuccessfulMessage($key);

        if ($request->wantsJson()) {
            $data = [
                $model
            ];

            return $this->validSuccessJsonResponse($message, $data);
        }

        return redirect()->route($this->getRedirectionRoute())
            ->with($this->infoFlashMessageKey, $message);
    }
934010
public function delete(string $version = HttpVersion::HTTP_1_1): HttpResponse
    {
        return HttpRequest::create($this->httpUri, $this->headers)
                ->delete($this->timeout, $version);
    }
616744
function delete($resource, $headers = array())
    {
        $result = $this->client->delete($this->build_url($resource), [
            'headers' => array_merge([
                'Authorization' => $this->getBearer()
            ], $headers)
        ]);
        return $result;
    }
13827
public function remove($resource)
    {
        $keysToRemove = array_keys($this->collection, $resource, true);
        $this->collection = array_values(array_diff_key($this->collection, array_flip($keysToRemove)));
        return $this;
    }