note 106736 added to splsubject.attach

From: Date: Fri, 02 Dec 2011 16:46:31 +0000
Subject: note 106736 added to splsubject.attach
Groups: php.notes 
Request: Send a blank email to php-notes+get-184860@lists.php.net to get a copy of this message
i think that Observer pattern is always implemented as "static" to be called from any scope, for example: <?php class Observer { //attach here the caller's scope private static $stackTrace = array( ); public static function wasTriggeredOnce() { //...if is not in the stack, then: self::$stackTrace[] = max( debug_backtrace( ) ); } } class YourFramework { public function launchPlatform() { //could not let user to launch application twice! Observer::wasTriggeredOnce(); } } //cause is static Observer::hereIsnoNeedToInstantiateAgain(); ?> ---- Server IP: 69.147.83.197 Probable Submitter: 85.9.36.2 ---- Manual Page -- http://www.php.net/manual/en/splsubject.attach.php Edit -- https://master.php.net/note/edit/106736 Del: integrated -- https://master.php.net/note/delete/106736/integrated Del: useless -- https://master.php.net/note/delete/106736/useless Del: bad code -- https://master.php.net/note/delete/106736/bad+code Del: spam -- https://master.php.net/note/delete/106736/spam Del: non-english -- https://master.php.net/note/delete/106736/non-english Del: in docs -- https://master.php.net/note/delete/106736/in+docs Del: other reasons-- https://master.php.net/note/delete/106736 Reject -- https://master.php.net/note/reject/106736 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#184860) next »