PHP Classes
elePHPant
Icontem

File: MyEventTest.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Xander Guzman  >  SigSlots  >  MyEventTest.php  >  Download  
File: MyEventTest.php
Role: Example script
Content type: text/plain
Description: Example.
Class: SigSlots
Trigger and process events with signal and slots
Author: By
Last change:
Date: 8 years ago
Size: 1,332 bytes
 

Contents

Class file image Download
<?php
   
require_once("sigslots.php");
   
    class
Button extends SigSlots
   
{
        private
$m_Id = null;
       
        public function
__construct($Id)
        {
           
$this->m_Id = $Id;
           
$this->_Initialize();
        }
       
        public function
__destruct() { }
       
        private function
_Initialize()
        {
           
$this->RegisterSignal("ButtonPress");
        }
       
        public function
Press()
        {
           
$this->EmitSignal("ButtonPress",array($this->m_Id,"Call Ted!"));
        }
    }
   
    class
Light extends SigSlots
   
{
        public function
__construct()
        {
           
$this->_Initialize();
        }
       
        public function
__destruct() { }
       
        private function
_Initialize()
        {
           
$this->RegisterSlot("ButtonPress","ButtonPressLight");
        }
       
        public function
ButtonPressLight($Id)
        {
            echo
"Light Activated by button: " . $Id . "\n";
        }
    }
   
    class
Alarm extends SigSlots
   
{
        public function
__construct()
        {
           
$this->_Initialize();
        }
       
        public function
__destruct() { }
       
        private function
_Initialize()
        {
           
$this->RegisterSlot("ButtonPress","ButtonPressAlarm");
        }
       
        public function
ButtonPressAlarm($Id,$Message)
        {
            echo
"Alarm Activated by button: " . $Id . " Message: " . $Message . "\n";
        }
    }
   
   
$Button = new Button(9782);
   
   
$Light = new Light();
   
$Alarm = new Alarm();
   
   
$Button->Press();
   

?>