Get download link `?file=` based on given path/uuid.

@param mixed $path File path/uuid
@param array $data Add custom data here

@return string File download link
171134
public function getDownloadLink($path, array $data = []): string
    {
        if (null === ($data = $this->getDownloadData($path, $data))) {
            return '';
        }

        return $data['href'];
    }
196439
protected function _downloadFile($path) {
        // Push up memory_limit to deal with large files
        $mem = new Garp_Util_Memory();
        $mem->useHighMemory();

        $bytes = @file_get_contents($path);
        if (!$bytes) {
            throw new Zend_Controller_Action_Exception('File not found.', 404);
        }

        $download = Zend_Controller_Action_HelperBroker::getStaticHelper('download');
        $download->force($bytes, basename($path), $this->_response);

        Zend_Controller_Front::getInstance()->setParam('noViewRenderer', true);
        $this->_helper->viewRenderer->setNoRender();
    }
1026332
public static function md($path, $data = [])
		{
			// find file
			$abspath = preg_match('%^(/|[a-z]:)%i', $path) === 1
				? $path
				: \View::getFinder()->find($path);

			// get contents
			$contents = file_get_contents($abspath);

			// update values
			$data['route'] = app(SketchpadConfig::class)->route;
			foreach ($data as $key => $value)
			{
				$contents = preg_replace('/\{\{\s*' .$key. '\s*\}\}/', $value, $contents);
			}

			// return
			return '<div data-format="markdown">' .$contents. '</div>';
		}
194549
public function get($path, array $data = array())
    {
        // If this given view has expired, which means it has simply been edited since
        // it was last compiled, we will re-compile the views so we can evaluate a
        // fresh copy of the view. We'll pass the compiler the path of the view.
        if ($this->compiler->isExpired($path))
        {
            $this->compiler->compile($path);
        }

        # SAVE VIEWS INFO IN SERVER DATA
        $_SERVER['view_used'] = realpath($path);

        $compiled = $this->compiler->getCompiledPath($path);

        return $this->evaluatePath($compiled, $data);
    }
1135267
public function getCuztomUrl($path = __FILE__, $url = [])
    {
        // Retun URL if defined
        if (defined('CUZTOM_URL')) {
            return CUZTOM_URL;
        }

        // Base vars
        $path = dirname($path);
        $path = str_replace('\\', '/', $path);
        $expath = explode('/', $path);
        $current = $expath[count($expath) - 1];

        // Push to path array
        array_push($url, $current);

        // Check for current
        if (preg_match('/content|app/', $current)) {
            $path = '';
            $directories = array_reverse($url);

            foreach ($directories as $dir) {
                if (! preg_match('/content|app/', $dir)) {
                    $path = $path.'/'.$dir;
                }
            }

            return apply_filters('cuztom_url', WP_CONTENT_URL.$path);
        } else {
            return $this->getCuztomUrl($path, $url);
        }
    }
324910
protected function getPathContent($data)
	{
		$info = file_get_contents($this->path);
		list($expires, $hits) = explode(',', $info);
		if ($expires <= time())
		{
			// it has expires
			unlink($this->path);
			$hits    = 0;
			$expires = null;
		}
		if ($data == 'hits')
		{
			return $hits;
		}
		if ($data == 'expires')
		{
			return $expires;
		}

		return null;
	}
125939
private function buildQuery(array $data, string $path = ''): string
    {
        if ([] === $data) {
            return '';
        }

        $query = '';
        foreach ($data as $key => $value) {
            if (null === $value) {
                continue;
            }

            $subPath = '' !== $path ? $path.'['.$key.']' : (string) $key;
            if (is_array($value)) {
                $query .= $this->buildQuery($value, $subPath);
            } else {
                $query .= $subPath.'='.urlencode($this->getValueAsString($value));
            }
            $query .= '&';
        }

        $query = substr($query, 0, -strlen('&'));

        return $query;
    }
107604
protected function view( $path, $data = array() ){
		return $this->view->render( $this->response, $path, $data );
	}
36048
public static function to($path, array $data = null )
	{
		//compose query string if data was set
		($data !== null) ? self::with($data) : '';

		//compose full url
		$path = (self::$query_string === null) ?  Url::link($path) : Url::link($path) . '?' . self::$query_string;

		//redirect to path
		header('Location: ' . $path);

		//stop any further html output
		exit();

	}
1081449
private function getDownloadUrlForFile($path)
    {
        $metadataRaw = $this->getMetadata($path)->getBody()->getContents();
        $metadata = json_decode($metadataRaw);

        return $metadata->{'@content.downloadUrl'};
    }
992681
public function prepend($path, $data)
	{
		if ($this->exists($path))
		{
			return $this->write($path, $data . $this->read($path));
		}

		return $this->write($path, $data);
	}
1334968
public function append($path, $data)
	{
		return $this->put($path, $this->get($path).PHP_EOL.$data);
	}
92661
public function getFileUrl($key, $path = null)
	{
		if (is_null($key)) {
			return null;
		}

		$bucket = config('filesystems.disks.s3.bucket');
		$client = Storage::disk('s3')->getAdapter()->getClient();

		return $this->getRealUrl($client->getObjectUrl($bucket, $path . $key));
	}
1220627
public function get($path, array $data = array())
    {
        // Instance Twig compiler.
        $twigCompiler = new TwigCompiler($this->app['config'], $this->app['view']);

        return $twigCompiler->render($path, $data);
    }
1023944
public static function url($path, array $data): string
    {
        $path = str_replace(' ', '%20', $path);

        return $path . '?' . http_build_query($data, '', '&', PHP_QUERY_RFC3986);
    }
914449
public static function path(array $data, $path, $default = null)
    {
        $path = (array) $path;

        foreach ($path as $key) {
            if (!is_array($data) || !array_key_exists($key, $data)) {
                return $default;
            }
            $data = $data[$key];
        }

        return $data;
    }
862300
public function get($path, array $data = [])
    {
        $contents = parent::get($path, $data);

        return $this->markdown->convertToHtml($contents);
    }