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.


Constructor summary

Attr. Name / Description
public

AssetSet($asset)

Construct an asset set.

Member summary

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.

Method summary

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.


Members


				
private \Scrivo\Asset $asset

The parent asset of the set.

Inital value: null


				
private \Scrivo\int[id] $ids

An array containing the keys of the items array, used when serializing.

Inital value: null


				
private \Scrivo\Asset[id] $items

The array containing the assets or asset ids.

Inital value: array()


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.

public __wakeup()

When unserializing restore the items array only the id.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

public rewind()

Rewind the asset set so that iterating will start at the beginning.

public boolean valid()

Test if the current asset is valid.

Returns:

boolean Test if the current asset is valid.


Documentation generated by phpDocumentor 2.0.0a12 and ScrivoDocumentor on August 29, 2013