Persists the resource to the storage engine.

@param \Hal\Resource $resource

@throws NotFoundHttpException if no client with the given id could be found.

@return null
190249
public function update(Resource $resource)
    {
        $data = $resource->toArray();

        /** @var ClientEntity $client */
        $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);
        }

        $client->setRedirectUris($data['redirectUris']);
        $client->setAllowedGrantTypes($data['grants']);

        $this->entityManager->persist($client);
        $this->entityManager->flush();
    }
814878
public function getResource($identifier)
    {
        /** @var UserEntity $user */
        $user = $this->userManager->findUserByUsername($identifier);
        if (!$user) {
            throw new NotFoundHttpException(
                $this->translator->trans('error.user_not_found', array('%id%' => $identifier))
            );
        }

        return $this->createResourceFromUser($user);
    }
1184029
protected function storeVersion(PuliResource $resource)
    {
        if (null !== $this->changeStream) {
            $this->changeStream->append($resource);
        }
    }
622206
public function get($resource)
    {
        if (!array_key_exists($resource, $this->resources)) {
            throw new \InvalidArgumentException(sprintf('This resource "%s" does not exist.', $resource));
        }

        $class = $this->resources[$resource];

        return new $class($this->client);
    }
1329564
public function getResourceUrl($resource)
    {
        Assert::oneOf(
            $resource,
            self::getResourcesNames(),
            'Resource type "%s" is not supported by the ACME server (supported: %2$s)'
        );

        return isset($this->serverResources[$resource]) ? $this->serverResources[$resource] : null;
    }
545173
protected function execute(ApiResourceInterface $resource)
    {
        $client = $resource->getHttpClient();

        if (is_null($options = $this->requestOptions())) {
            return $client->request($this->requestMethod(), $this->requestUrl($resource));
        }

        return $client->request($this->requestMethod(), $this->requestUrl($resource), $options);
    }
1232360
public function update_($resource, ...$id) {
		$this->_checkResource ( $resource, function () use ($id) {
			if (! $this->hasErrors ()) {
				parent::_update ( ...$id );
			} else {
				echo $this->displayErrors ();
			}
		} );
	}
726847
public function deleteResource(PersistentResource $resource)
    {
        $pathAndFilename = $this->getStoragePathAndFilenameByHash($resource->getSha1());
        if (!file_exists($pathAndFilename)) {
            return true;
        }
        if (unlink($pathAndFilename) === false) {
            return false;
        }
        Files::removeEmptyDirectoriesOnPath(dirname($pathAndFilename));
        return true;
    }
1009587
protected function setupCreateReference($resource)
    {
        foreach ($resource->settings['actions']['CreateReference']['uris'] as $property => $uri) {
            $this->setupCreate($resource, $uri, $property);
        }
    }
666206
public function persistResource(RestfulModel $resource)
    {
        try {
            $resource->save();
        } catch (\Exception $e) {
            // Check for QueryException - if so, we may want to display a more meaningful message, or help with
            // development debugging
            if ($e instanceof QueryException) {
                if (stristr($e->getMessage(), 'duplicate')) {
                    throw new ConflictHttpException('The resource already exists: ' . $this->model);
                } elseif (Config::get('api.debug') === true) {
                    throw $e;
                }
            }

            // Default HTTP exception to use for storage errors
            $errorMessage = 'Unexpected error trying to store this resource.';

            if (Config::get('api.debug') === true) {
                $errorMessage .= ' ' . $e->getMessage();
            }

            throw new UnprocessableEntityHttpException($errorMessage);
        }

        return $resource;
    }
663280
public function getResource($resource)
    {
        if (array_key_exists($resource, $this->cache)) {
            return $this->cache[$resource];
        }

        if (!array_key_exists($resource, $this->resources)) {
            throw new ResourceNotImplemented($resource);
        }

        $params = $this->resources[$resource];
        $instance = $params['instance'];

        if (is_null($instance)) {
            $class = $params['class'];

            $instance = new $class($this);
        }

        return $this->cache[$resource] = $instance;
    }
41985
private function findResource($resource, array &$criteria)
    {
        array_walk_recursive($criteria, function (&$value) {
            if ($value === 'yes') {
                $value = true;
            } elseif ($value === 'no') {
                $value = false;
            }
        });

        $this->getManager($resource)->clear();

        return $this->getRepository($resource)->findOneBy($criteria);
    }
1040901
public ResponseBuilder initialize(final Resource resource) {

        if (MISSING_RESOURCE.equals(resource)) {
            throw new NotFoundException();
        } else if (DELETED_RESOURCE.equals(resource)) {
            throw new ClientErrorException(GONE);
        }

        setResource(resource);
        return status(NO_CONTENT);
    }
1323437
public function setConnectionResource($resource): void
    {
        if ($this->subtypeConverter instanceof ConnectionAware) {
            $this->subtypeConverter->setConnectionResource($resource);
        }
    }
953887
protected function handleResource(array $resources)
    {
        //  Fall through is to process just like a no-resource request
        $resources = $this->getResourceHandlers();
        if ((false !== $resources) && !empty($this->resource)) {
            if (in_array($this->resource, $resources)) {
                return $this->processRequest();
            }
        }

        throw new NotFoundException("Resource '{$this->resource}' not found for service '{$this->name}'.");
    }
766816
public function setConnectionResource($resource): void
    {
        foreach ($this->items as $converter) {
            if ($converter instanceof ConnectionAware) {
                $converter->setConnectionResource($resource);
            }
        }
    }
791954
public function getPublicPersistentResourceUri(PersistentResource $resource)
    {
        if ($this->baseUri != '') {
            return $this->baseUri . $this->encodeRelativePathAndFilenameForUri($this->getRelativePublicationPathAndFilename($resource));
        } else {
            return $this->s3Client->getObjectUrl($this->bucketName, $this->keyPrefix . $this->getRelativePublicationPathAndFilename($resource));
        }
    }