mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-02 13:07:27 +02:00
A simple example for Observer Pattern
This commit is contained in:
@@ -59,7 +59,7 @@ class User implements \SplSubject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -86,4 +86,9 @@ class User implements \SplSubject
|
|||||||
// notify the observers, that user has been updated
|
// notify the observers, that user has been updated
|
||||||
$this->notify();
|
$this->notify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$user = new User();
|
||||||
|
$user->attach(new UserObserver());
|
||||||
|
|
||||||
|
$user->notify();
|
||||||
|
Reference in New Issue
Block a user