AbstractContainer
extends AbstractResource
in package
Abstract class holding shared functionality for containers.
Table of Contents
- GLOBAL_METADATA_PREFIX = 'X'
- PATCH_CONTENT_TYPE = OpenCloudCommonConstantsMime::JSON_PATCH
- $name : string
- The name of the container.
- $aliases : array<string|int, mixed>
- The aliases configure for the properties of the instance.
- $metadata : Metadata
- $metadataClass : string
- $service : ServiceInterface
- $logger : LoggerInterface
- The logger instance
- $properties : array<string|int, mixed>
- Holds all the properties added by overloading.
- __call() : mixed
- Intercept non-existent method calls for dynamic getter/setter functionality.
- __construct() : mixed
- appendToMetadata() : array<string|int, mixed>
- Append a particular array of values to the existing metadata. Analogous to a merge. You must call to actually persist the metadata using the ObjectStore service.
- checkJsonError() : mixed
- Checks the most recent JSON operation for errors.
- fromResponse() : AbstractResource
- Factory method that allows for easy instantiation from a Response object.
- generateUuid() : mixed
- getCdnService() : Service
- For internal use only.
- getClient() : Client
- For internal use only.
- getInstance() : static
- getLogger() : LoggerInterface
- Returns the Logger object.
- getMetadata() : Metadata
- Returns metadata for this object.
- getService() : Service
- For internal use only.
- getTransId() : string
- Return the transaction ID for an HTTP API operation. Useful for debugging.
- getUrl() : Url
- For internal use only
- hasLogger() : bool
- hasLogRetention() : bool
- Returns whether this container has log retention enabled or not.
- isCdnEnabled() : bool
- Returns whether this container is CDN-enabled or not.
- makeResourceIteratorOptions() : mixed
- populate() : mixed
- Populates the current object based on an unknown data type.
- primaryKeyField() : string
- For internal use only
- retrieveMetadata() : Metadata
- Retrieve metadata from the API. This method will then set and return this value.
- saveMetadata() : Response
- Push local metadata to the API, thereby executing a permanent save.
- setLogger() : $this
- Sets the logger.
- setMetadata() : AbstractResource
- Set the metadata (local-only) for this object. You must call saveMetadata to actually persist the metadata using the ObjectStore service.
- setStaticErrorPage() : Response
- Set the default error page for your static site.
- setStaticIndexPage() : Response
- This method will enable your CDN-enabled container to serve out HTML content like a website.
- stockHeaders() : array<string|int, mixed>
- Prepend/stock the header names with a resource-specific prefix.
- stripNamespace() : mixed
- toCamel() : mixed
- Convert a string to camelCase format.
- toUnderscores() : mixed
- Convert string to underscore format.
- trimHeaders() : array<string|int, mixed>
- Trim headers of their resource-specific prefixes.
- unsetMetadataItem() : Response
- To delete or unset a particular metadata item.
- url() : mixed
- createRefreshRequest() : mixed
- getJsonHeader() : mixed
- getPatchHeaders() : mixed
- getProperty() : mixed
- Grab value out of the data array.
- headerIsValidMetadata() : mixed
- propertyExists() : bool
- Basic check to see whether property exists.
- setProperty() : mixed
- We can set a property under three conditions:
- stripPrefix() : mixed
- Strip an individual header name of its resource-specific prefix.
- checkAttributePrefix() : bool
- Checks the attribute $property and only permits it if the prefix is in the specified $prefixes array
- isAccessible() : bool
- Does the property exist in the object variable list (i.e. does it have public or protected visibility?)
Constants
GLOBAL_METADATA_PREFIX
public
mixed
GLOBAL_METADATA_PREFIX
= 'X'
PATCH_CONTENT_TYPE
public
mixed
PATCH_CONTENT_TYPE
= OpenCloudCommonConstantsMime::JSON_PATCH
Properties
$name
The name of the container.
public
string
$name
The only restrictions on container names is that they cannot contain a forward slash (/) and must be less than 256 bytes in length. Please note that the length restriction applies to the name after it has been URL encoded. For example, a container named Course Docs would be URL encoded as Course%20Docs - which is 13 bytes in length rather than the expected 11.
$aliases
The aliases configure for the properties of the instance.
protected
array<string|int, mixed>
$aliases
= array()
$metadata
protected
Metadata
$metadata
$metadataClass
protected
string
$metadataClass
= 'OpenCloud\ObjectStore\Resource\ContainerMetadata'
The FQCN of the metadata object used for the container.
$service
protected
ServiceInterface
$service
The service object.
$logger
The logger instance
private
LoggerInterface
$logger
$properties
Holds all the properties added by overloading.
private
array<string|int, mixed>
$properties
= array()
Methods
__call()
Intercept non-existent method calls for dynamic getter/setter functionality.
public
__call( $method, $args) : mixed
Parameters
Tags
Return values
mixed —__construct()
public
__construct(ServiceInterface $service[, mixed $data = null ]) : mixed
Parameters
- $service : ServiceInterface
- $data : mixed = null
Return values
mixed —appendToMetadata()
Append a particular array of values to the existing metadata. Analogous to a merge. You must call to actually persist the metadata using the ObjectStore service.
public
appendToMetadata(array<string|int, mixed> $values) : array<string|int, mixed>
Parameters
- $values : array<string|int, mixed>
-
The array of values you want to append to metadata.
Return values
array<string|int, mixed> —Metadata, after $values are appended.
checkJsonError()
Checks the most recent JSON operation for errors.
public
static checkJsonError() : mixed
Tags
Return values
mixed —fromResponse()
Factory method that allows for easy instantiation from a Response object.
public
static fromResponse(Response $response, ServiceInterface $service) : AbstractResource
For internal use only.
Parameters
- $response : Response
-
HTTP response from an API operation.
- $service : ServiceInterface
-
The ObjectStore service to associate with this ObjectStore resource object.
Return values
AbstractResource —A concrete sub-class of AbstractResource.
generateUuid()
public
static generateUuid() : mixed
Return values
mixed —getCdnService()
For internal use only.
public
getCdnService() : Service
Return values
Service —The CDN version of the ObjectStore service associated with this ObjectStore resource.
getClient()
For internal use only.
public
getClient() : Client
Return values
Client —The HTTP client associated with the associated ObjectStore service.
getInstance()
public
static getInstance() : static
Return values
static —getLogger()
Returns the Logger object.
public
getLogger() : LoggerInterface
Return values
LoggerInterface —getMetadata()
Returns metadata for this object.
public
getMetadata() : Metadata
Return values
Metadata —Metadata set on this object.
getService()
For internal use only.
public
getService() : Service
Return values
Service —The ObjectStore service associated with this ObjectStore resource.
getTransId()
Return the transaction ID for an HTTP API operation. Useful for debugging.
public
getTransId() : string
Return values
string —Transaction ID
getUrl()
For internal use only
public
getUrl([string $path = null ][, array<string|int, mixed> $params = array() ]) : Url
Parameters
- $path : string = null
-
Path to add to URL. Optional.
- $params : array<string|int, mixed> = array()
-
Query parameters to add to URL. Optional.
Return values
Url —URL of this container + path + query parameters.
hasLogger()
public
hasLogger() : bool
Return values
bool —hasLogRetention()
Returns whether this container has log retention enabled or not.
public
hasLogRetention() : bool
Return values
bool —true if this container has log retention enabled; false, otherwise.
isCdnEnabled()
Returns whether this container is CDN-enabled or not.
public
abstract isCdnEnabled() : bool
Return values
bool —true if this container is CDN-enabled; false, otherwise.
makeResourceIteratorOptions()
public
makeResourceIteratorOptions(mixed $resource) : mixed
Parameters
- $resource : mixed
Return values
mixed —populate()
Populates the current object based on an unknown data type.
public
populate(mixed $info[, mixed $setObjects = true ]) : mixed
Parameters
- $info : mixed
- $setObjects : mixed = true
Tags
Return values
mixed —primaryKeyField()
For internal use only
public
primaryKeyField() : string
Return values
string —Name of the primary key field for this resource
retrieveMetadata()
Retrieve metadata from the API. This method will then set and return this value.
public
retrieveMetadata() : Metadata
Return values
Metadata —Metadata returned from the ObjectStore service for this object/container.
saveMetadata()
Push local metadata to the API, thereby executing a permanent save.
public
saveMetadata(array<string|int, mixed> $metadata[, bool $stockPrefix = true ]) : Response
Parameters
- $metadata : array<string|int, mixed>
-
The array of values you want to set as metadata
- $stockPrefix : bool = true
-
Whether to prepend each array key with the metadata-specific prefix. For objects, this would be X-Object-Meta-Foo => Bar
Return values
Response —HTTP response from API operation.
setLogger()
Sets the logger.
public
setLogger([LoggerInterface $logger = null ]) : $this
Parameters
- $logger : LoggerInterface = null
Return values
$this —setMetadata()
Set the metadata (local-only) for this object. You must call saveMetadata to actually persist the metadata using the ObjectStore service.
public
setMetadata(array<string|int, mixed> $data[, bool $constructFromResponse = false ]) : AbstractResource
Parameters
- $data : array<string|int, mixed>
-
Object/container metadata key/value pair array.
- $constructFromResponse : bool = false
-
Whether the metadata key/value pairs were obtiained from an HTTP response of an ObjectStore API operation.
Return values
AbstractResource —This object, with metadata set.
setStaticErrorPage()
Set the default error page for your static site.
public
setStaticErrorPage(mixed $page) : Response
Parameters
- $page : mixed
Return values
Response —The HTTP response for this operation.
setStaticIndexPage()
This method will enable your CDN-enabled container to serve out HTML content like a website.
public
setStaticIndexPage(mixed $page) : Response
Parameters
- $page : mixed
Return values
Response —The HTTP response for this API operation.
stockHeaders()
Prepend/stock the header names with a resource-specific prefix.
public
static stockHeaders(array<string|int, mixed> $headers) : array<string|int, mixed>
Parameters
- $headers : array<string|int, mixed>
-
Headers to use on ObjectStore resource.
Return values
array<string|int, mixed> —Headers returned with appropriate prefix as expected by ObjectStore service.
stripNamespace()
public
stripNamespace(mixed $namespace) : mixed
Parameters
- $namespace : mixed
Return values
mixed —toCamel()
Convert a string to camelCase format.
public
toCamel( $string[, bool $capitalise = true ]) : mixed
Parameters
Return values
mixed —toUnderscores()
Convert string to underscore format.
public
toUnderscores( $string) : mixed
Parameters
Return values
mixed —trimHeaders()
Trim headers of their resource-specific prefixes.
public
static trimHeaders(array<string|int, mixed> $headers) : array<string|int, mixed>
For internal use only.
Parameters
- $headers : array<string|int, mixed>
-
Headers as returned from an HTTP response
Return values
array<string|int, mixed> —Trimmed headers
unsetMetadataItem()
To delete or unset a particular metadata item.
public
unsetMetadataItem( $key) : Response
Parameters
Return values
Response —HTTP response returned from API operation to unset metadata item.
url()
public
url([mixed $path = null ][, array<string|int, mixed> $query = array() ]) : mixed
Parameters
- $path : mixed = null
- $query : array<string|int, mixed> = array()
Tags
Return values
mixed —createRefreshRequest()
protected
createRefreshRequest() : mixed
Return values
mixed —getJsonHeader()
protected
static getJsonHeader() : mixed
Return values
mixed —getPatchHeaders()
protected
static getPatchHeaders() : mixed
Return values
mixed —getProperty()
Grab value out of the data array.
protected
getProperty(string $property) : mixed
Parameters
- $property : string
Return values
mixed —headerIsValidMetadata()
protected
static headerIsValidMetadata(mixed $header) : mixed
Parameters
- $header : mixed
Return values
mixed —propertyExists()
Basic check to see whether property exists.
protected
propertyExists(string $property[, bool $allowRetry = true ]) : bool
Parameters
- $property : string
-
The property name being investigated.
- $allowRetry : bool = true
-
If set to TRUE, the check will try to format the name in underscores because there are sometimes discrepancies between camelCaseNames and underscore_names.
Return values
bool —setProperty()
We can set a property under three conditions:
protected
setProperty(mixed $property, mixed $value) : mixed
- If it has a concrete setter: setProperty()
- If the property exists
- If the property name's prefix is in an approved list
Parameters
- $property : mixed
- $value : mixed
Return values
mixed —stripPrefix()
Strip an individual header name of its resource-specific prefix.
protected
static stripPrefix( $header) : mixed
Parameters
Return values
mixed —checkAttributePrefix()
Checks the attribute $property and only permits it if the prefix is in the specified $prefixes array
private
checkAttributePrefix(string $property) : bool
This is to support extension namespaces in some services.
Parameters
- $property : string
-
the name of the attribute
Return values
bool —isAccessible()
Does the property exist in the object variable list (i.e. does it have public or protected visibility?)
private
isAccessible( $property) : bool