Sets up given cURL resource with desired parameters.

@param resource $resource
181478
public function decorate($resource)
    {
        curl_setopt($resource, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt(
            $resource,
            CURLOPT_PROXY,
            sprintf(
                '%s:%s',
                $this->proxyHost,
                $this->proxyPort
            )
        );

        if ($this->proxyUser && $this->proxyPassword) {
            curl_setopt(
                $resource,
                CURLOPT_PROXYUSERPWD,
                sprintf(
                    '%s:%s',
                    $this->proxyUser,
                    $this->proxyPassword
                )
            );
        }
    }
877102
protected function setupIndexReferences($resource)
    {
        foreach ($resource->settings['actions']['IndexReferences']['uris'] as $property => $uri) {
            $this->setupIndex($resource, $uri, $property);
        }
    }
627256
public function setResource(PersistentResource $resource)
    {
        $this->lastModified = new \DateTime();
        $this->resource = $resource;
        $this->refresh();
    }
396956
private function init(string $url): void
    {
        $this->resource = curl_init($url);

        curl_setopt($this->resource, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($this->resource, CURLOPT_CONNECTTIMEOUT, $this->loader->getTimeout());
        curl_setopt($this->resource, CURLOPT_USERAGENT, $this->loader->getUserAgent());
        curl_setopt($this->resource, CURLOPT_HEADER, true);
        curl_setopt($this->resource, CURLINFO_HEADER_OUT, true);

        // check and set proxy settings
        $proxy_host = $this->loader->getOption('ProxyHost');

        if (null !== $proxy_host) {
            // check for supported protocol
            $proxy_protocol = $this->loader->getOption('ProxyProtocol');

            if (null !== $proxy_protocol) {
                $allowedProtocolls = [StreamCreator::PROXY_PROTOCOL_HTTP, StreamCreator::PROXY_PROTOCOL_HTTPS];

                if (!in_array($proxy_protocol, $allowedProtocolls)) {
                    throw new Exception(
                        'Invalid/unsupported value "' . $proxy_protocol . '" for option "ProxyProtocol".',
                        Exception::INVALID_OPTION
                    );
                }
            } else {
                $proxy_protocol = StreamCreator::PROXY_PROTOCOL_HTTP;
            }

            $proxy_port = $this->loader->getOption('ProxyPort');

            // set basic proxy options
            curl_setopt($this->resource, CURLOPT_PROXY, $proxy_protocol . '://' . $proxy_host);
            if (null !== $proxy_port) {
                curl_setopt($this->resource, CURLOPT_PROXYPORT, $proxy_port);
            }

            // check auth settings
            $proxy_user = $this->loader->getOption('ProxyUser');

            // set proxy auth options
            if (null !== $proxy_user) {
                $proxy_password = $this->loader->getOption('ProxyPassword');

                $proxy_auth = $this->loader->getOption('ProxyAuth');
                if (null !== $proxy_auth) {
                    $allowedAuth = [StreamCreator::PROXY_AUTH_BASIC, StreamCreator::PROXY_AUTH_NTLM];

                    if (!in_array($proxy_auth, $allowedAuth)) {
                        throw new Exception(
                            'Invalid/unsupported value "' . $proxy_auth . '" for option "ProxyAuth".',
                            Exception::INVALID_OPTION
                        );
                    }
                } else {
                    $proxy_auth = StreamCreator::PROXY_AUTH_BASIC;
                }

                if (StreamCreator::PROXY_AUTH_NTLM === $proxy_auth) {
                    curl_setopt($this->resource, CURLOPT_PROXYAUTH, CURLAUTH_NTLM);
                }
                curl_setopt($this->resource, CURLOPT_PROXYUSERPWD, $proxy_user . ':' . $proxy_password);
            }
        }
    }
229779
static public function createFromResource($resource) {
		if (!is_resource($resource))
			throw new Exception('Invalid (resource) parameter! This is not a resource!');
		if (get_resource_type($resource) != 'gd')
			throw new Exception('Invalid (resource) parameter! Resource is not a gd resource!');
		return new self($resource);
	}
1072041
protected function _setupCurl($curlConnection)
    {
        if ($this->getConnection()->hasConfig('curl')) {
            foreach ($this->getConnection()->getConfig('curl') as $key => $param) {
                \curl_setopt($curlConnection, $key, $param);
            }
        }
    }
766816
public function setConnectionResource($resource): void
    {
        foreach ($this->items as $converter) {
            if ($converter instanceof ConnectionAware) {
                $converter->setConnectionResource($resource);
            }
        }
    }
1374366
public function apply($resource){
		// Extract arguments
		@list(,$mask,$xinit,$yinit)=func_get_args();
		if(is_subclass_of($mask,'Imagix\AbstractImage')){
			$mask=$mask->getResource();
		}
		elseif(!is_resource($mask)){
			throw new Exception("The 'mask' parameter must be a valid GD resource or a Lumy_File_Image child object");
		}
		// Prepare
		$w_mask=imagesx($mask);
		$h_mask=imagesy($mask);
		if($w_mask===false || $h_mask===false){
			throw new Exception("An error was encountered while getting mask image resolution");
		}
		$width=imagesx($resource);
		$height=imagesy($resource);
		if($width===false || $height===false){
			throw new Exception("An error was encountered while getting source image resolution");
		}
		$xinit=(int)$xinit;
		$yinit=(int)$yinit;
		if($xinit<0)				$xinit=0;
		if($xinit>$width-$w_mask)	$xinit=$width-$w_mask;
		if($yinit<0)				$yinit=0;
		if($yinit>$height-$h_mask)	$yinit=$height-$h_mask;
		// Create new image
		$image=$this->_createTrueColor($width,$height);
		if(!imagecopy($image,$resource,0,0,0,0,$width,$height)){
			throw new Exception("Cannot copy image");
		}
		// Modify colors
		$x=$xinit;
		do{
			$y=$yinit;
			do{
				// Get pixel color from source image
				$rgba_src=$this->_getColorAt($image,$x,$y);
				// Get pixel color from mask image
				$rgba_mask=$this->_getColorAt($mask,$x-$xinit,$y-$yinit);
				// Generate alpha
				if($rgba_mask[0]==$rgba_mask[1] && $rgba_mask[1]==$rgba_mask[2]){
					$alpha=floor($rgba_mask[0]/2)+$rgba_src[3];
					if($alpha>127) $alpha=127;
				}
				else{
					throw new Exception("Mask image must be in grayscale");
				}
				// Define new pixel
				$color=imagecolorallocatealpha($image,$rgba_src[0],$rgba_src[1],$rgba_src[2],$alpha);
				if($color===false){
					throw new Exception("Cannot allocate color");
				}
				if(!imagesetpixel($image,$x,$y,$color)){
					throw new Exception("Cannot set pixel");
				}
			}
			while(++$y<$h_mask+$yinit);
		}
		while(++$x<$w_mask+$xinit);
		return $image;
	}
285936
public function load($resource)
    {
        $jsonDecoder = new JsonDecoder();
        $jsonDecoder->setObjectDecoding(JsonDecoder::ASSOC_ARRAY);

        $config = $jsonDecoder->decode($this->repository->get($resource)->getBody());

        // Keep track of this file being loaded to prevent infinite recursion
        $this->loadedFiles[$resource] = true;

        $this->includeDesc($config);
        $this->mergeIncludes($config);

        return $config;
    }
1057040
public function update(Resource $resource)
    {
        $data = $resource->toArray();

        $user = $this->userManager->findUserByUsername($data['username']);
        if (!$user) {
            $errorMessage = $this->translator->trans('error.user_not_found', array('%username%' => $data['username']));
            throw new NotFoundHttpException($errorMessage);
        }

        $user->setUsername($data['username']);
        $user->setEmail($data['email']);
        $user->setPlainPassword($data['password']);
        $user->setEnabled(true);
        $this->userManager->updateUser($user);
    }
1120057
protected function addResource($resource)
    {
        $resource = trim($resource);
        if (strlen($resource)) {
            $this->resources[] = $resource;
        }
    }
461765
public function postAction( $resource )
	{
		$response = $this->createAdmin( $resource )->post( $this->getPsrRequest(), new Response() );
		return $this->setPsrResponse( $response );
	}
912232
public function put($resource, $data = [])
    {
        $exec = $this->execute(Method::$HTTP_PUT, $resource, ['json' => $data]);

        return $exec;
    }
1023503
public function addEmbedResource(AbstractResource $resource)
    {
        if (!in_array($resource, $this->embedResources)) {
            // Uses node ID as array key in order to avoid duplicates
            $this->embedResources[$resource->getResourceNode()->getId()] = $resource;
        }
    }
912376
public function create($resource)
    {
        $className = $this->getResourceClassName($resource->type);
        if (!class_exists($className)) {
            throw new Exception(
                'Unknown resource type "' . $resource->type . '".',
                Exception::UNKNOWN_RESOURCE_TYPE
            );
        }

        /** @var AbstractResource $object */
        $object = $this->objectManager->get($className);

        foreach ($resource as $property => $value) {
            if (!ObjectAccess::isPropertySettable($object, $property)) {
                continue;
            }
            ObjectAccess::setProperty($object, $property, $value);
        }

        $this->postProcessResources($object);

        return $object;
    }
533953
public function onResourceCreated(\core_kernel_classes_Resource $resource) {
        foreach ($this->getInner() as $impl) {
            $impl->onResourceCreated($resource);
        }
    }
447029
protected function fillAttributes($resource, array $attributes)
    {
        foreach ($attributes as $attribute => $value) {
            $setter = "set" . ucfirst($attribute);

            if (method_exists($resource, $setter)) {
                $resource->$setter($value);
            }
        }
    }