class AcquiaDAM_Assets_Folder in Media: Acquia DAM 7
Acquia DAM asset implmentation for Folder assets.
@package AcquiaDAM
Hierarchy
- class \AcquiaDAM_Assets_AbstractAsset implements \ArrayAccess, \JsonSerializable
- class \AcquiaDAM_Assets_Folder
Expanded class hierarchy of AcquiaDAM_Assets_Folder
File
- src/
AcquiaDAM/ AcquiaDAM_Assets_Folder.inc, line 8
View source
class AcquiaDAM_Assets_Folder extends AcquiaDAM_Assets_AbstractAsset {
/**
* The ID of what is considered the Root folder.
*
* @var int
*/
const ROOT_FOLDER_ID = 0;
/**
* Return the API endpoint base.
*
* {@inheritDoc}
*
* @return string
* The base slug to use in API requests.
*/
protected function getEndpointBase() {
return 'folders';
}
/**
* Get the asset type identifier.
*
* {@inheritDoc}
*
* @return string
* The asset type machine name.
*/
public function getType() {
return 'folder';
}
/**
* Retrieve the Root folder listing.
*
* @return AcquiaDAM_Assets_Folder[]
* An array of folders located at the root.
*/
public function getRoot() {
$result = [];
$rootFolders = $this
->request('folders');
if (!empty($rootFolders)) {
foreach ($rootFolders as $folder) {
$result[] = new static($folder, $this->depends);
}
}
return $result;
}
/**
* Get assets located in the folder.
*
* @param array $options
* Options to pass to the API request.
* @param bool $fullyLoad
* TRUE to fully load returned assets.
*
* @return array
* An array containing child folders and asset items.
*/
public function getAssets(array $options = [], $fullyLoad = FALSE) {
$this
->requireId();
$options += [
'sortby' => 'filename',
'sortdir' => 'desc',
'limit' => 50,
'offset' => 0,
];
$result = $this
->request(sprintf('folders/%d/assets', $this->asset['id']), $options);
$mapping = [
'items' => 'asset',
'folders' => 'folder',
];
foreach ($mapping as $key => $type) {
if (!empty($result[$key]) && is_array($result[$key])) {
$result[$key] = array_map(function ($item) use ($type, $fullyLoad) {
$id = $fullyLoad ? $item['id'] : $item;
return media_acquiadam_get_helper($type, $id, $this->depends);
}, $result[$key]);
}
}
return $result;
}
/**
* Get parents of this folder.
*
* @param int[] $parents
* An array of existing parent IDs.
*
* @return int[]
* An array of parent IDs.
*/
public function getParents(array $parents = []) {
if (!empty($this['parent'])) {
$parents[] = $this['parent'];
$parent = new static($this['parent']);
return $parent
->getParents($parents);
}
return $parents;
}
/**
* Gets the path to this asset within the DAM web interface.
*
* {@inheritDoc}
*/
public function getDAMPath() {
$this
->get();
return sprintf('cloud/#folder/%d', $this->asset['id']);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AcquiaDAM_Assets_AbstractAsset:: |
protected | property | Asset information as returned by the API. | |
AcquiaDAM_Assets_AbstractAsset:: |
protected | property | The asset ID. | |
AcquiaDAM_Assets_AbstractAsset:: |
protected | property | A list of class dependencies. | |
AcquiaDAM_Assets_AbstractAsset:: |
protected | function | Make sure the given ID is valid to be used as an asset ID. | |
AcquiaDAM_Assets_AbstractAsset:: |
public | function | Fetch the asset from the API. | |
AcquiaDAM_Assets_AbstractAsset:: |
protected | function | Gets the client object for use. | |
AcquiaDAM_Assets_AbstractAsset:: |
public | function | Gets the URL to the asset within the DAM provider. | |
AcquiaDAM_Assets_AbstractAsset:: |
public | function | Get multiple assets at once. | |
AcquiaDAM_Assets_AbstractAsset:: |
public | function | Get the URL to the DAM-provided preview if possible. | |
AcquiaDAM_Assets_AbstractAsset:: |
public static | function | Get a list of possible pregenerated thumbnail sizes. | |
AcquiaDAM_Assets_AbstractAsset:: |
public | function | Get the URL to the DAM-provided thumbnail if possible. | |
AcquiaDAM_Assets_AbstractAsset:: |
public | function | Checks if the current asset is expired. | |
AcquiaDAM_Assets_AbstractAsset:: |
public | function | Implementation for JsonSerializable. | |
AcquiaDAM_Assets_AbstractAsset:: |
public | function | Implementation for ArrayAccess. | |
AcquiaDAM_Assets_AbstractAsset:: |
public | function | Implementation for ArrayAccess. | |
AcquiaDAM_Assets_AbstractAsset:: |
public | function | Implementation for ArrayAccess. | |
AcquiaDAM_Assets_AbstractAsset:: |
public | function | Implementation for ArrayAccess. | |
AcquiaDAM_Assets_AbstractAsset:: |
protected | function | Client request wrapper. | |
AcquiaDAM_Assets_AbstractAsset:: |
protected | function | Ensure we have an asset ID set. | |
AcquiaDAM_Assets_AbstractAsset:: |
public | function | Set the asset ID for the current asset. | |
AcquiaDAM_Assets_AbstractAsset:: |
public | function | Get an array representation of this asset. | |
AcquiaDAM_Assets_AbstractAsset:: |
public | function | Create an Asset. | |
AcquiaDAM_Assets_AbstractAsset:: |
public | function | Return a string representation of this asset. | |
AcquiaDAM_Assets_Folder:: |
public | function | Get assets located in the folder. | |
AcquiaDAM_Assets_Folder:: |
public | function |
Gets the path to this asset within the DAM web interface. Overrides AcquiaDAM_Assets_AbstractAsset:: |
|
AcquiaDAM_Assets_Folder:: |
protected | function |
Return the API endpoint base. Overrides AcquiaDAM_Assets_AbstractAsset:: |
|
AcquiaDAM_Assets_Folder:: |
public | function | Get parents of this folder. | |
AcquiaDAM_Assets_Folder:: |
public | function | Retrieve the Root folder listing. | |
AcquiaDAM_Assets_Folder:: |
public | function |
Get the asset type identifier. Overrides AcquiaDAM_Assets_AbstractAsset:: |
|
AcquiaDAM_Assets_Folder:: |
constant | The ID of what is considered the Root folder. |