Class \Scrivo\AssetSet
A Scrivo Asset set is a group of Scrivo assets with a common parent id.
A asset set is actually a simple array of (child) assets but it does a couple of things extra:
- When serialized only the ids are stored.
- When iteratering, counting or getting assets from the array only the readable assets in the array will be taken into account.
Asset sets are a part of a Scrivo asset and are used to retrieve and iterate through the child assets (or path) of an asset.
Implements
Defined in:
AssetSet.php.
Attr. | Name / Description |
---|---|
public |
AssetSet($asset) Construct an asset set. |
Attr. | Type | Name | Description |
---|---|---|---|
private | \..\Asset | $asset | The parent asset of the set. |
private | \..\int[] | $ids | An array containing the keys of the items array, used when serializing. |
private | \..\Asset[] | $items | The array containing the assets or asset ids. |
Attr. | Type | Name / Description |
---|---|---|
public |
__sleep() When serializing retrieve the don't store the items array but just the keys. |
|
public |
__wakeup() When unserializing restore the items array only the id. |
|
private |
check($id) When reading the items array always check of the actual entry is an instantiated Scrivo asset. |
|
public | int |
count() The asset count of assets in the set. |
public | \..\Asset |
current() Get the current asset from the asset set when iterating. |
public | \..\Asset |
key() Get the key(id) of the current asset from the asset set when iterating. |
public | \..\Asset |
next() Get the current asset from the asset set and move the internal pointer to the next asset in the set. |
public | boolean |
offsetExists($id) Test if asset is set in the asset set. |
public | \..\Asset |
offsetGet($id) Get an asset with a specific id from the asset set. |
public |
offsetSet($id, $asset) Set an asset in the asset set. |
|
public |
offsetUnset($id) It is not possible to unset assets in an asset set. |
|
public |
prepend($asset) Add an asset to the beginning of the set. |
|
public |
rewind() Rewind the asset set so that iterating will start at the beginning. |
|
public | boolean |
valid() Test if the current asset is valid. |
Constructor
- public AssetSet(\Scrivo\Asset $asset)
-
Construct an asset set.
Parameters:
Type Name Def. Description \Scrivo\Asset $asset The parent asset of the asset set.
View source: AssetSet.php line 90.
Members
- private \Scrivo\Asset $asset
-
The parent asset of the set.
Inital value: null
View source: AssetSet.php line 62.
- private \Scrivo\int[id] $ids
-
An array containing the keys of the items array, used when serializing.
Inital value: null
View source: AssetSet.php line 68.
- private \Scrivo\Asset[id] $items
-
The array containing the assets or asset ids.
Inital value: array()
View source: AssetSet.php line 56.
Methods
- public __sleep()
-
When serializing retrieve the don't store the items array but just the keys.
return array An array with the names of the serializable members.
View source: AssetSet.php line 242.
- public __wakeup()
-
When unserializing restore the items array only the id.
View source: AssetSet.php line 255.
- private check(int $id)
-
When reading the items array always check of the actual entry is an instantiated Scrivo asset.
If not, get that asset and store it in the items array.
Parameters:
Type Name Def. Description int $id The asset id of the entry to check.
View source: AssetSet.php line 77.
- public int count()
-
The asset count of assets in the set.
Note that returned asset count depends on whether the assets are readable for the user defined in the Scrivo context. So the returned count is always equeal or less that the actual count of assets in the items array.
Returns:
int The asset count of assets in the set.
View source: AssetSet.php line 225.
- public \Scrivo\Asset current()
-
Get the current asset from the asset set when iterating.
Returns:
\Scrivo\Asset Get the current asset from the asset set when iterating.
View source: AssetSet.php line 166.
- public \Scrivo\Asset key()
-
Get the key(id) of the current asset from the asset set when iterating.
Returns:
\Scrivo\Asset Get the key(id) of the current asset from the asset set when iterating.
View source: AssetSet.php line 175.
- public \Scrivo\Asset next()
-
Get the current asset from the asset set and move the internal pointer to the next asset in the set.
Returns:
\Scrivo\Asset Get the current asset from the asset set and move the internal pointer to the next asset in the set.
View source: AssetSet.php line 185.
- public boolean offsetExists(int $id)
-
Test if asset is set in the asset set.
Parameters:
Type Name Def. Description int $id A Scrivo asset id to test.
Returns:
boolean Test if asset is set in the asset set.
View source: AssetSet.php line 125.
- public \Scrivo\Asset offsetGet(int $id)
-
Get an asset with a specific id from the asset set.
Parameters:
Type Name Def. Description int $id A Scrivo asset id to test.
Returns:
\Scrivo\Asset Get an asset with a specific id from the asset set.
View source: AssetSet.php line 147.
- public offsetSet(int $id, \Scrivo\Asset $asset)
-
Set an asset in the asset set.
Parameters:
Type Name Def. Description int $id A Scrivo asset id.
\Scrivo\Asset $asset The parent asset of the asset set.
View source: AssetSet.php line 103.
- public offsetUnset(int $id)
-
It is not possible to unset assets in an asset set.
Calling this method will raise a system exception.
Parameters:
Type Name Def. Description int $id A Scrivo asset id to unset.
View source: AssetSet.php line 136.
- public prepend(\Scrivo\Asset $asset)
-
Add an asset to the beginning of the set.
Parameters:
Type Name Def. Description \Scrivo\Asset $asset The parent asset of the asset set.
View source: AssetSet.php line 112.
- public rewind()
-
Rewind the asset set so that iterating will start at the beginning.
View source: AssetSet.php line 157.
- public boolean valid()
-
Test if the current asset is valid.
Returns:
boolean Test if the current asset is valid.
View source: AssetSet.php line 194.
Documentation generated by phpDocumentor 2.0.0a12 and ScrivoDocumentor on August 29, 2013