Path

ez components / documentation / api reference / trunk / signalslot


eZ Components trunk

SignalSlot: ezcSignalCollection

[ Tutorial ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

Class: ezcSignalCollection

ezcSignalCollection implements a mechanism for inter and intra object communication. [source]
See the tutorial for extensive examples on how to use this class.

Properties

string read  $identifier
The identifier of this signal collection. Usually the class name of the object containing the collection.
bool read/write  $signalsBlocked
If set to true emits will not cause any slots to be called.

Method Summary

public ezcSignalCollection __construct( [$identifier = "default"], [$options = array()] )
Constructs a new signal collection with the identifier $identifier.
public void connect( $signal, $slot, [$priority = 1000] )
Connects the signal $signal to the slot $slot.
public void disconnect( $signal, $slot, [$priority = null] )
Disconnects the $slot from the $signal.
public void emit( $signal, $signal_parameters )
Emits the signal with the name $signal
public ezcSignalCollectionOptions getOptions( )
Returns the options for this class.
public static ezcSignalStaticConnectionsBase getStaticConnectionsHolder( )
Returns the current provider of static connections or null if there is none.
public bool isConnected( $signal )
Returns true if any slots have been connected to the signal $signal.
public void setOptions( $options )
Sets the options of this class.
public static void setStaticConnectionsHolder( $holder )
If set, $holder will be used to fetch static connections instead of ezcSignalStaticConnections.
public mixed __get( $name )
Returns the property $name.
public void __set( $name, $value )
Sets the property $name to $value.

Methods

__construct

ezcSignalCollection __construct( [string $identifier = "default"], [ $options = array()] )
Constructs a new signal collection with the identifier $identifier.
The identifier can be used to connect to signals statically using ezcSignalStaticConnections.
Through the associative array options you can specify the options for this class in the format array( 'optionName' => value ). See the documentation of ezcSignalCollectionOptions for information on the available options.

Parameters

Name Type Description
$identifier string  
$options array  

connect

void connect( string $signal, callback $slot, [int $priority = 1000] )
Connects the signal $signal to the slot $slot.
To control the order in which slots are called you can set a priority from 1 - 65 536. The lower the number the higher the priority. The default priority is 1000. Slots with the same priority may be called with in any order.
A slot will be called once for every time it is connected. It is possible to connect a slot more than once.
See the PHP documentation for examples on the callback type. http://php.net/callback.
We recommend avoiding excessive usage of the $priority parameter since it makes it much harder to track how your program works.

Parameters

Name Type Description
$signal string  
$slot callback  
$priority int  

Throws

ClassDescription
ezcSignalSlotException if the signals options has been set and $signal is not in the list of signals.

disconnect

void disconnect( string $signal, callback $slot, [int $priority = null] )
Disconnects the $slot from the $signal.
If the priority is given it will try to disconnect a slot with that priority. If no such slot is found no slot will be disconnected.
If no priority is given it will disconnect the matching slot with the lowest priority.

Parameters

Name Type Description
$signal string  
$slot callback  
$priority int  

Throws

ClassDescription
ezcSignalSlotException if the signals options has been set and $signal is not in the list of signals.

emit

void emit( string $signal, ... $signal_parameters )
Emits the signal with the name $signal
Any additional parameters are sent as parameters to the slot.

Parameters

Name Type Description
$signal string  
$signal_parameters ...  

Throws

ClassDescription
ezcSignalSlotException if the signals options has been set and $signal is not in the list of signals.

getOptions

Returns the options for this class.

getStaticConnectionsHolder

ezcSignalStaticConnectionsBase getStaticConnectionsHolder( )
Returns the current provider of static connections or null if there is none.

isConnected

bool isConnected( string $signal )
Returns true if any slots have been connected to the signal $signal.
False is returned if no slots have been connected to the $signal.
Note: Emitting the signal $signal may still not call any slots if the property signalsBlocked has been set.

Parameters

Name Type Description
$signal string  

Throws

ClassDescription
ezcSignalSlotException if the signals options has been set and $signal is not in the list of signals.

setOptions

void setOptions( ezcSignalCollectionOptions|array(string=>value) $options )
Sets the options of this class.

Parameters

Name Type Description
$options ezcSignalCollectionOptions|array(string=>value) The options to set either as an associative array in the form array(optionName=>value) or a ezcSignalCollectionOptions object.

Throws

ClassDescription
ezcBaseSettingNotFoundException If you tried to set a non-existent option value.
ezcBaseSettingValueException If the value is not valid for the desired option.
ezcBaseValueException If you submit neither an array nor an instance of ezcSignalCollectionOptions.

setStaticConnectionsHolder

void setStaticConnectionsHolder( ezcSignalStaticConnectionsBase $holder )
If set, $holder will be used to fetch static connections instead of ezcSignalStaticConnections.

Parameters

Name Type Description
$holder ezcSignalStaticConnectionsBase  

__get

mixed __get( string $name )
Returns the property $name.

Parameters

Name Type Description
$name string  

Throws

ClassDescription
ezcBasePropertyNotFoundException if the property does not exist.

__set

void __set( string $name, mixed $value )
Sets the property $name to $value.

Parameters

Name Type Description
$name string  
$value mixed  

Throws

ClassDescription
ezcBasePropertyNotFoundException if the property does not exist.

Last updated: Mon, 10 Nov 2008