Ejemplo n.º 1
0
 public function testStaticSignalsFromOtherSource()
 {
     $norris = new Fire();
     ezcSignalCollection::setStaticConnectionsHolder($norris);
     $signals = new ezcSignalCollection();
     $signals->emit("chuck");
     $this->assertEquals(1, $norris->fired);
 }
Ejemplo n.º 2
0
 protected function setUp()
 {
     $this->giver = new TheGiver();
     $this->receiver = new TheReceiver();
     TheReceiver::$globalFunctionRun = false;
     TheReceiver::$staticFunctionRun = false;
     ezcSignalStaticConnections::getInstance()->connections = array();
     ezcSignalCollection::setStaticConnectionsHolder(new EmptyStaticConnections());
 }
<?php

require_once 'tutorial_autoload.php';
class customLazySignalConfiguration implements ezcBaseConfigurationInitializer
{
    public static function configureObject($signal)
    {
        $signal->connect('default', 'signal', 'customFunction');
    }
}
ezcBaseInit::setCallback('ezcInitSignalStaticConnections', 'customLazySignalConfiguration');
function customFunction()
{
    echo "Custom function called with:\n", var_export(func_get_args(), true);
}
$signals = new ezcSignalCollection();
$signals->emit('signal', 42);
<?php

require_once 'tutorial_autoload.php';
class HelloClass
{
    public function hello()
    {
        echo "Hello world\n";
    }
}
$signals = new ezcSignalCollection();
$signals->connect("sayHello", array(new HelloClass(), "hello"));
$signals->emit("sayHello");
Ejemplo n.º 5
0
<?php

// Connect signals to slots.
$signals = new ezcSignalCollection();
$receiver = new MyReceiver();
$signals->connect('afterExecutionStarted', array($receiver, 'afterExecutionStarted'));
$signals->connect('afterExecutionSuspended', array($receiver, 'afterExecutionSuspended'));
$signals->connect('afterExecutionResumed', array($receiver, 'afterExecutionResumed'));
$signals->connect('afterExecutionCancelled', array($receiver, 'afterExecutionCancelled'));
$signals->connect('afterExecutionEnded', array($receiver, 'afterExecutionEnded'));
$signals->connect('beforeNodeActivated', array($receiver, 'beforeNodeActivated'));
$signals->connect('afterNodeActivated', array($receiver, 'afterNodeActivated'));
$signals->connect('afterNodeExecuted', array($receiver, 'afterNodeExecuted'));
$signals->connect('afterRolledBackServiceObject', array($receiver, 'afterRolledBackServiceObject'));
$signals->connect('afterThreadStarted', array($receiver, 'afterThreadStarted'));
$signals->connect('afterThreadEnded', array($receiver, 'afterThreadEnded'));
$signals->connect('beforeVariableSet', array($receiver, 'beforeVariableSet'));
$signals->connect('afterVariableSet', array($receiver, 'afterVariableSet'));
$signals->connect('beforeVariableUnset', array($receiver, 'beforeVariableUnset'));
$signals->connect('afterVariableUnset', array($receiver, 'afterVariableUnset'));
// Set up database connection.
$db = ezcDbFactory::create('mysql://test@localhost/test');
// Set up workflow definition storage (database).
$definition = new ezcWorkflowDatabaseDefinitionStorage($db);
// Load latest version of workflow named "Test".
$workflow = $definition->loadByName('Test');
// Set up database-based workflow executer.
$execution = new ezcWorkflowDatabaseExecution($db);
// Pass workflow object to workflow executer.
$execution->workflow = $workflow;
// Register SignalSlot workflow engine plugin.
Ejemplo n.º 6
0
 /**
  * If set, $holder will be used to fetch static connections instead of ezcSignalStaticConnections.
  *
  * @param ezcSignalStaticConnectionsBase $holder
  */
 public static function setStaticConnectionsHolder(ezcSignalStaticConnectionsBase $holder)
 {
     self::$staticConnectionsHolder = $holder;
 }
<?php

require_once 'tutorial_autoload.php';
class HelloClass
{
    public static function hello()
    {
        echo "Hello world\n";
    }
}
$signals = new ezcSignalCollection();
$signals->connect("sayHello", array("HelloClass", "hello"));
$signals->emit("sayHello");
<?php

require_once 'tutorial_autoload.php';
function hello()
{
    echo "Hello world\n";
}
$signals = new ezcSignalCollection();
$signals->connect("sayHello", "hello");
$signals->emit("sayHello");