Generate a response object for a cached image.

@param string $path Path to the cached image

@return bool
769263
private function serveFromCache($path)
    {
        //try and load the image from the cache
        if ($this->cache->has($path)) {
            $file = $this->cache->get($path);

            $lastModified = new \DateTime();
            $lastModified->setTimestamp($file->getTimestamp());

            $this->setHttpCacheHeaders(
                $lastModified,
                md5($this->getCachePath().$lastModified->getTimestamp()),
                $this->maxAge
            );

            // Respond with 304 not modified
            if ($this->response->isNotModified($this->request)) {
                return true;
            }

            $this->response = new StreamedResponse();

            // Set the headers
            $this->response->headers->set('Content-Type', $file->getMimetype());
            $this->response->headers->set('Content-Length', $file->getSize());

            $this->setHttpCacheHeaders(
                $lastModified,
                md5($this->getCachePath().$lastModified->getTimestamp()),
                $this->maxAge
            );

            $this->response->setCallback(function () use ($file) {
                fpassthru($file->readStream());
            });

            return true;
        }

        return false;
    }
370075
public function getFile($path)
    {
        $file = new File($this->getFileSystemId(), $this->getFullPath($path));
        $file->setServiceLocator($this->getServiceLocator());
        return $file;
    }
342742
public function load($path)
    {
        $path = $this->findAbsolutePath($path);

        if ($this->cache) {
            if ($this->cache->isFresh($path, filemtime($path))) {
                $feature = $this->cache->read($path);
            } elseif (null !== $feature = $this->parseFeature($path)) {
                $this->cache->write($path, $feature);
            }
        } else {
            $feature = $this->parseFeature($path);
        }

        return null !== $feature ? array($feature) : array();
    }
745130
public function createFolder($path) : bool
	{
		$path = $this->normalizePath($path);
		
		// Check if the path contains folders we dont want to create
		if (str_contains($path, $this->folderPathExcludeList)) {
			return true;
		}
		
		$this->folderPath = '/sites/'.$this->siteName.'/Shared%20Documents';
		
		$requestUrl = $this->siteUrl.'/sites/'.$this->siteName.'/_api/Web/folders';
		
		$this->requestHeaders['Content-Type'] = 'application/json;odata=verbose';
		
		$folderAttributes = [
			'__metadata' => [
				'type' => 'SP.Folder',
			],
			'ServerRelativeUrl' => $this->folderPath.$path,
		];
		
		$options = [
			'headers' => $this->requestHeaders,
			'body' => json_encode($folderAttributes)
		];
		
		$response = $this->send('POST', $requestUrl, $options);
		
		return $response->getStatusCode() === 200 ? true : false;
	}
711244
public function md5File($path)
    {
        if (! $this->isFile($path))
            return false;
        return md5($this->at($path)->content);
    }
1329099
public function image($path)
    {
        if (gplcart_path_is_absolute($path)) {
            $file = $path;
            $url = gplcart_path_relative($path);
        } else {

            $path = gplcart_path_normalize($path);
            $prefix = gplcart_path_relative(GC_DIR_FILE);

            if (strpos($path, "$prefix/") === 0) {
                $url = $path;
                $file = gplcart_file_absolute($path);
            } else {
                $url = "$prefix/$path";
                $file = gplcart_path_absolute($path);
            }
        }

        $query = is_file($file) ? array('v' => filemtime($file)) : array();

        return $this->get($url, $query, false, true);
    }
1268075
protected function readObject($path)
    {
        $options = [
            'Bucket' => $this->bucket,
            'Key'    => $this->applyPathPrefix($path),
        ];

        if (isset($this->options['@http'])) {
            $options['@http'] = $this->options['@http'];
        }

        $command = $this->s3Client->getCommand('getObject', $options + $this->options);

        try {
            /** @var Result $response */
            $response = $this->s3Client->execute($command);
        } catch (S3Exception $e) {
            return false;
        }

        return $this->normalizeResponse($response->toArray(), $path);
    }
145730
private function createImageFrom($path)
    {

        $this->gdExtensionCheck();
        switch ($this->getExt()) {
            case 'jpg':
                return imagecreatefromjpeg($path);
                break;
            case 'png':
                return imagecreatefrompng($path);
                break;
            case 'gif':
                return imagecreatefromgif($path);
                break;

            default:
                return imagecreatefrompng($path);
                break;
        }

    }
561898
public function getThemeUrl($path = '')
    {
        if (!is_null($path) && ! is_bool($path) && ! is_string($path) && !is_numeric($path)) {
            $path = is_resource($path) ? '' : gettype($path);
        }

        $path = (string) $path;
        if (!isset($this->cachedPath)) {
            $this->cachedPath = substr($this->getThemePath(), strlen(dirname($_SERVER['SCRIPT_FILENAME'])));
        }

        $path = $this->cachedPath . ltrim($path, '/');
        return $this->getBaseUrl($path);
    }
1331137
public static function sessionSavePath($path = null)
    {
        if (PHP_SAPI != 'cli') {
            return $path ? session_save_path($path) : session_save_path();
        }
        if ($path && is_dir($path) && is_writable($path) && !static::sessionStarted()) {
            HttpCache::$sessionPath = $path;
        }
        return HttpCache::$sessionPath;
    }
128129
public function renderByPathAction($path = '')
    {
        /**
         * @var PageInterface $page
         */
        $page = $this
            ->pageRepository
            ->findOneByPath($path);

        return $this
            ->pageResponseTransformer
            ->createResponseFromPage(
                $page,
                $path
            );
    }
812159
private function createImage($path) {
		$mime = $this->mimeType($path);
      
		if ($mime[2] == 'jpg') {
			return imagecreatefromjpeg ($path);
		} else if ($mime[2] == 'png') {
			return imagecreatefrompng ($path);
		} else {
			return false; 
		} 
    }
1067613
public function getCacheKey($path)
    {
        try {
            // Even though the path and $path are the same, call the locator to
            // make sure that the path actually exists
            // The result of this method MUST NOT be the real path (without
            // prefix), because then the generated file has the same cache
            // key as the same template loaded through a different loader.
            // If loaded through a different loader, relative paths won't be
            // resolved, so we'll have the wrong version of the template in
            // he cache.
            return '__puli__'.$this->getResource($path)->getPath();
        } catch (ResourceNotFoundException $e) {
            throw new Twig_Error_Loader($e->getMessage(), -1, null, $e);
        } catch (InvalidArgumentException $e) {
            throw new Twig_Error_Loader($e->getMessage(), -1, null, $e);
        }
    }
451557
public function create(FilesystemInterface $cache, $path)
    {
        $resource = $cache->readStream($path);
        if ($resource === false) {
            throw new ResponseException();
        }
        $stream = new Stream($resource);

        $contentType = $cache->getMimetype($path);
        $contentLength = $cache->getSize($path);

        if ($contentType === false) {
            throw new FilesystemException('Unable to determine the image content type.');
        }

        if ($contentLength === false) {
            throw new FilesystemException('Unable to determine the image content length.');
        }

        return (new Response())->withBody($stream)
            ->withHeader('Content-Type', $contentType)
            ->withHeader('Content-Length', $contentLength);
    }
1267544
public function getImageUrl($path, $style=null)
    {
        if (empty($style)){
            return $this->imageHost.$this->prefix.$path;
        }
        return $this->imageHost.$this->prefix.$path.'@!'.$style;
    }
397584
protected function get_imageinfo_from_path($path) {
        $imageinfo = getimagesize($path);

        $image = array(
                'width'     => $imageinfo[0],
                'height'    => $imageinfo[1],
                'mimetype'  => image_type_to_mime_type($imageinfo[2]),
            );
        if (empty($image['width']) or empty($image['height']) or empty($image['mimetype'])) {
            // GD can not parse it, sorry.
            return false;
        }
        return $image;
    }
1237499
private function isCached(string $path)
	{
		$views = glob($this->cacheDirectory . $this->DS . '*'. str_replace($this->DS, '___', $path));

		if (count($views) > 0) {
			$this->canRecache($path, $views[0]);
			return file_get_contents($views[0]) == null ? ' ' : file_get_contents($views[0]);
		}
		else {
			$this->cache($path, uniqid());
		}

		$views = glob($this->cacheDirectory . $this->DS . '*'. str_replace($this->DS, '___', $path));
		if (count($views) > 0) {
			return file_get_contents($views[0]) == null ? ' ' : file_get_contents($views[0]);
		}
	}