PHP Interface Imbo\Database\DatabaseInterface

This is an interface for storage adapters in Imbo.
Author: Christer Edvartsen ([email protected])
Datei anzeigen Open project: imbo/imbo

Public Methods

Method Description
deleteImage ( string $user, string $imageIdentifier ) : boolean Delete an image from the database
deleteMetadata ( string $user, string $imageIdentifier ) : boolean Delete all metadata associated with an image
deleteShortUrls ( string $user, string $imageIdentifier, string $shortUrlId = null ) : boolean Delete short URLs attached to a specific image, or a single short URL
getImageMimeType ( string $user, string $imageIdentifier ) : string Get the mime type of an image
getImageProperties ( string $user, string $imageIdentifier ) : array Fetch image properties from the database
getImages ( array $users, Query $query, Images $model ) : array Get images based on some query parameters
getLastModified ( array $users, string $imageIdentifier = null ) : DateTime Get the last modified timestamp for given users
getMetadata ( string $user, string $imageIdentifier ) : array Get all metadata associated with an image
getNumBytes ( string $user = null ) : integer Fetch the number of bytes stored, optionally filtered by a given user
getNumImages ( string $user = null ) : integer Fetch the number of images, optionally filtered by a given user
getNumUsers ( ) : integer Fetch the number of users which has one or more images
getShortUrlId ( string $user, string $imageIdentifier, string $extension = null, array $query = [] ) : string | null Fetch the short URL identifier
getShortUrlParams ( string $shortUrlId ) : array | null Fetch parameters for a short URL
getStatus ( ) : boolean Get the current status of the database connection
imageExists ( string $user, string $imageIdentifier ) : boolean Check if an image already exists
insertImage ( string $user, string $imageIdentifier, Image $image ) : boolean Insert a new image
insertShortUrl ( string $shortUrlId, string $user, string $imageIdentifier, string $extension = null, array $query = [] ) : boolean Insert a short URL
load ( string $user, string $imageIdentifier, Image $image ) : boolean Load information from database into the image object
updateMetadata ( string $user, string $imageIdentifier, array $metadata ) : boolean Edit metadata

Method Details

deleteImage() public method

Delete an image from the database
public deleteImage ( string $user, string $imageIdentifier ) : boolean
$user string The user which the image belongs to
$imageIdentifier string Image identifier
return boolean Returns true on success or false on failure

deleteMetadata() public method

Delete all metadata associated with an image
public deleteMetadata ( string $user, string $imageIdentifier ) : boolean
$user string The user which the image belongs to
$imageIdentifier string Image identifier
return boolean Returns true on success or false on failure

deleteShortUrls() public method

Delete short URLs attached to a specific image, or a single short URL
public deleteShortUrls ( string $user, string $imageIdentifier, string $shortUrlId = null ) : boolean
$user string The user attached to the URL
$imageIdentifier string The image identifier attached to the URL
$shortUrlId string Specify to delete a single short URL for a specific image owned by a user
return boolean

getImageMimeType() public method

Get the mime type of an image
public getImageMimeType ( string $user, string $imageIdentifier ) : string
$user string The user which the image belongs to who owns the image
$imageIdentifier string The image identifier
return string Returns the mime type of the image

getImageProperties() public method

Fetch image properties from the database
public getImageProperties ( string $user, string $imageIdentifier ) : array
$user string The user which the image belongs to
$imageIdentifier string The image identifier
return array

getImages() public method

This method is also responsible for setting a correct "hits" number in the images model.
public getImages ( array $users, Query $query, Images $model ) : array
$users array The users which the images belongs to
$query Imbo\Resource\Images\Query A query instance
$model Imbo\Model\Images The images model
return array

getLastModified() public method

If the $imageIdentifier parameter is set, return when that image was last updated. If not set, return the most recent date when one of the specified users last updated any image. If the provided users does not have any images stored, return the current timestamp.
public getLastModified ( array $users, string $imageIdentifier = null ) : DateTime
$users array The users
$imageIdentifier string The image identifier
return DateTime Returns an instance of DateTime

getMetadata() public method

Get all metadata associated with an image
public getMetadata ( string $user, string $imageIdentifier ) : array
$user string The user which the image belongs to
$imageIdentifier string Image identifier
return array Returns the metadata as an array

getNumBytes() public method

Fetch the number of bytes stored, optionally filtered by a given user
public getNumBytes ( string $user = null ) : integer
$user string The user which the images belongs to (pass null to count for all users)
return integer Returns the number of bytes

getNumImages() public method

Fetch the number of images, optionally filtered by a given user
public getNumImages ( string $user = null ) : integer
$user string The user which the images belongs to (pass null to count for all users)
return integer Returns the number of images

getNumUsers() public method

Fetch the number of users which has one or more images
public getNumUsers ( ) : integer
return integer Returns the number of users

getShortUrlId() public method

Fetch the short URL identifier
public getShortUrlId ( string $user, string $imageIdentifier, string $extension = null, array $query = [] ) : string | null
$user string The user attached to the URL
$imageIdentifier string The image identifier attached to the URL
$extension string Optionl image extension
$query array Optional query parameters
return string | null

getShortUrlParams() public method

Fetch parameters for a short URL
public getShortUrlParams ( string $shortUrlId ) : array | null
$shortUrlId string The ID of the short URL
return array | null Returns an array with information regarding the short URL, or null if the short URL is not found

getStatus() public method

This method is used with the status resource.
public getStatus ( ) : boolean
return boolean

imageExists() public method

Check if an image already exists
public imageExists ( string $user, string $imageIdentifier ) : boolean
$user string The user which the image belongs to who owns the image
$imageIdentifier string The image identifier
return boolean Returns true of the image exists, false otherwise

insertImage() public method

This method will insert a new image into the database. If the same image already exists, just update the "updated" information.
public insertImage ( string $user, string $imageIdentifier, Image $image ) : boolean
$user string The user which the image belongs to
$imageIdentifier string Image identifier
$image Imbo\Model\Image The image to insert
return boolean Returns true on success or false on failure

insertShortUrl() public method

Insert a short URL
public insertShortUrl ( string $shortUrlId, string $user, string $imageIdentifier, string $extension = null, array $query = [] ) : boolean
$shortUrlId string The ID of the URL
$user string The user attached to the URL
$imageIdentifier string The image identifier attached to the URL
$extension string Optionl image extension
$query array Optional query parameters
return boolean

load() public method

Load information from database into the image object
public load ( string $user, string $imageIdentifier, Image $image ) : boolean
$user string The user which the image belongs to
$imageIdentifier string The image identifier
$image Imbo\Model\Image The image object to populate
return boolean

updateMetadata() public method

Edit metadata
public updateMetadata ( string $user, string $imageIdentifier, array $metadata ) : boolean
$user string The user which the image belongs to
$imageIdentifier string Image identifier
$metadata array An array with metadata
return boolean Returns true on success or false on failure