mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-12 19:06:24 +02:00
Merge pull request #17 from scoumbourdis/cb4a9de3be436bb5ae1f1d9460dab449e137ae07
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