setPlugin() public method

Stores a reference to the plugin instance that created the event.
public setPlugin ( Phergie_Plugin_Abstract $plugin ) : Phergie_Event_Command
$plugin Phergie_Plugin_Abstract Plugin instance
return Phergie_Event_Command Provides a fluent interface
コード例 #1
0
ファイル: Handler.php プロジェクト: Bittarman/phergie
 /**
  * Adds an event to the queue.
  *
  * @param Phergie_Plugin_Abstract $plugin Plugin originating the event
  * @param string                  $type   Event type, corresponding to a 
  *        Phergie_Event_Command::TYPE_* constant
  * @param array                   $args   Optional event arguments
  *
  * @return Phergie_Event_Handler Provides a fluent interface
  */
 public function addEvent(Phergie_Plugin_Abstract $plugin, $type, array $args = array())
 {
     if (!defined('Phergie_Event_Command::TYPE_' . strtoupper($type))) {
         throw new Phergie_Event_Exception('Unknown event type "' . $type . '"', Phergie_Event_Exception::ERR_UNKNOWN_EVENT_TYPE);
     }
     $event = new Phergie_Event_Command();
     $event->setPlugin($plugin)->setType($type)->setArguments($args);
     $this->events[] = $event;
     return $this;
 }
コード例 #2
0
ファイル: CommandTest.php プロジェクト: rdohms/phergie
 /**
  * Tests that a plugin can be associated with an event.
  *
  * @return void
  */
 public function testSetPlugin()
 {
     $plugin = $this->getMock('Phergie_Plugin_Abstract');
     $this->event->setPlugin($plugin);
     $this->assertSame($plugin, $this->event->getPlugin());
 }