public function __invoke()

in src/View/Helper/CloudFrontLink.php [98:126]


    public function __invoke($object, $domain = '', $expiration = '', $keyPairId = '', $privateKey = '')
    {
        if (empty($domain)) {
            $domain = $this->getDefaultDomain();
        }

        // If $domain is still empty, we throw an exception as it makes no sense
        if (empty($domain)) {
            throw new InvalidDomainNameException('An empty CloudFront domain name was given');
        }

        $url = sprintf(
            'https://%s%s/%s',
            str_replace($this->hostname, '', rtrim($domain, '/')),
            $this->hostname,
            ltrim($object, '/')
        );

        if (empty($expiration)) {
            return $url;
        }

        return $this->client->getSignedUrl([
            'url'         => $url,
            'expires'     => $expiration,
            'key_pair_id' => $keyPairId,
            'private_key' => $privateKey
        ]);
    }