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