/** * Runs a remote function call. * * @param int $storageUid The UID of the drivers storage. * @param string $function The name of the function that should be called. * @param array $parameters The parameters passed to the remote function. * @return mixed The return value of the remote function. */ public function call($storageUid, $function, $parameters = array()) { $parameters = base64_encode(serialize($parameters)); $hash = GeneralUtility::hmac($storageUid . $function . $parameters, 'fal_remote'); $report = array(); $url = $this->extensionConfiguration->getRemoteTypo3Url() . sprintf('?eID=fal_remote&hash=%s&storageUid=%d&function=%s¶meters=%s', $hash, (int) $storageUid, rawurlencode($function), $parameters); $result = GeneralUtility::getUrl($url, 0, FALSE, $report); if (!$result) { throw new \RuntimeException('Error fetching file information for ' . $function . ': ' . $report['message']); } $result = json_decode($result, TRUE); if (empty($result['success'])) { $error = !empty($result['error']) ? ': ' . $result['error'] : ''; throw new \RuntimeException('Error fetching file information for ' . $function . $error); } return $result['returnValue']; }
/** * Returns the public URL to a file. * For the local driver, this will always return a path relative to PATH_site. * * @param string $identifier * @return string * @throws \TYPO3\CMS\Core\Resource\Exception */ public function getPublicUrl($identifier) { $publicUrl = parent::getPublicUrl($identifier); if (!empty($publicUrl)) { $publicUrl = rtrim($this->extensionConfiguration->getRemoteTypo3Url(), '/') . '/' . ltrim($publicUrl, '/'); } return $publicUrl; }