cloudinary-8.x-1.x-dev/modules/cloudinary_media_library_widget/src/Service/CloudinaryFileHelperInterface.php
modules/cloudinary_media_library_widget/src/Service/CloudinaryFileHelperInterface.php
<?php
namespace Drupal\cloudinary_media_library_widget\Service;
use Drupal\file\FileInterface;
use Drupal\media\MediaInterface;
/**
* Build an interface for cloudinary file helper service.
*/
interface CloudinaryFileHelperInterface {
/**
* Get asset public id from the file uri.
*
* @param string $uri
* The uri of the file.
*
* @return string
* The public id of the asset.
*/
public static function getPublicIdFromFileUri(string $uri): string;
/**
* Get raw transformation from media entity.
*
* Use this method to support old and new way.
*
* @param \Drupal\media\MediaInterface $media
* The media entity.
*
* @return string|null
* The raw asset transformation.
*/
public static function getRawTransformationByMedia(MediaInterface $media): ?string;
/**
* Generate uri for file entity.
*
* Note, we don't store transformation in file uri.
*
* @param string $value
* Custom string value from the form element.
* @param bool $allow_overrides
* Allow overrides to change extension of the asset dynamically to support
* a thumbnail generation for files like pdf.
*
* @return string
* The uri of the file.
*/
public function generateUriForFile(string $value, bool $allow_overrides = TRUE): string;
/**
* Generate uri for file entity with transformation.
*
* @param string $value
* Custom string value from the form element.
*
* @return string
* The uri of the file.
*/
public function generateUriForFileWithTransformation(string $value): string;
/**
* Generate uri for external url.
*
* Note, this uri is not used for file entity.
*
* @param string $value
* Custom string value from the form element.
*
* @return string
* The uri to generate external url.
*/
public function generateUriForExternalUrl(string $value): string;
/**
* Create a file entity from custom string value.
*
* The file entity is used for cloudinary custom field type as a reference.
*
* @param string $value
* Custom string value from the form element.
*
* @return \Drupal\file\FileInterface
* The newly created file.
*/
public function createFile(string $value): FileInterface;
}
