Wanneer casino weer open South Holland

  1. Roulette Wiel: Wed liefde om u een mooie gemakkelijke manier om een overwinning te garanderen wanneer u klikt om te draaien.
  2. Gratis Casino I Mobilen - Rekening houdend met alles, heeft dit Grosvenor beoordeling denk dat deze operator heeft het recht om zichzelf te labelen als de meest populaire casino in het Verenigd Koninkrijk.
  3. Wat Heb Je Nodig Om Bingo Te Spelen: Jagen prooi groter dan zichzelf, terwijl heimelijk negeren van hun vijand early warning systeem is slechts een van de vele coole combinaties in het spel.

Winkans bij loterijen

Wild Spells Online Gokkast Spelen Gratis En Met Geld
We hebben deze download online casino's door middel van een strenge beoordeling proces om ervoor te zorgen dat u het meeste uit uw inzetten wanneer u wint.
Nieuwe Gokkasten Gratis
Dit betekent dat het hangt af van wat inkomstenbelasting bracket je in, en of de winst zal duwen u in een andere bracket.
The delight is de geanimeerde banner met de welkomstpromotie bij de eerste duik je in.

Pokersites voor Enschedeers

Nieuw Casino
De reel set is 7x7, met een totaal van 49 symbolen in het spel.
Casigo Casino 100 Free Spins
Holland Casino Eindhoven is een vestiging waar veel georganiseerd op het gebied van entertainment..
Casino Spel Gratis Slots

Sjoerd Maessen blog

PHP and webdevelopment

PHP hook, building hooks in your application

with 98,458 comments

Introduction
One of the real challenges in building any type of framework, core or application is making it possible for the developers to hook into the business logic at specific points. Since PHP is not event based, nor it works with interrupts you have to come up an alternative.

The test case
Lets assume we are the main developers of a webshop framework. Programmers can use our framework to build complete webshops. Programmers can manage the orders that are placed on the webshop with the order class. The order class is part of our framework and we don’t want it to be extended by any programmer. However we don’t want to limit to programmers in their possibilities to hook into the orders process.

For example programmers should be able to send an email to the webshopowner if an order changes from one specific delivery status to another. This functionality is not part of the default behavior in our framework and is custom for the progammers webshop implementation.

Like said before, PHP doesn’t provide interrupts or real events so we need to come up with another way to implement hooks into our application. Lets take a look at the observer pattern.

Implementing the Observer pattern
The observer pattern is a design-pattern that describes a way for objects to be notified to specific state-changes in objects of the application.

For the first implementation we can use SPL. The SPL provides in two simple objects:

SPLSubject

  • attach (new observer to attach)
  • detach (existing observer to detach)
  • notify (notify all observers)

SPLObserver

  • update (Called from the subject (i.e. when it’s value has changed).
iOrderRef = $iOrderRef;
		
		// Get order information from the database or an other resources
		$this->iStatus = Order::STATUS_SHIPPED;
	}
	
	/**
	 * Attach an observer
	 * 
	 * @param SplObserver $oObserver 
	 * @return void
	 */
	public function attach(SplObserver $oObserver)
	{
		$sHash = spl_object_hash($oObserver);
		if (isset($this->aObservers[$sHash])) {
			throw new Exception('Observer is already attached');
		}

		$this->aObservers[$sHash] = $oObserver;
	}

	/**
	 * Detach observer
	 * 
	 * @param SplObserver $oObserver 
	 * @return void
	 */
	public function detach(SplObserver $oObserver)
	{
		$sHash = spl_object_hash($oObserver);
		if (!isset($this->aObservers[$sHash])) {
			throw new Exception('Observer not attached');
		}
		unset($this->aObservers[$sHash]);
	}

	/**
	 * Notify the attached observers
	 * 
	 * @param string $sEvent, name of the event
	 * @param mixed $mData, optional data that is not directly available for the observers
	 * @return void
	 */
	public function notify()
	{
		foreach ($this->aObservers as $oObserver) {
			try {
				$oObserver->update($this);
			} catch(Exception $e) {

			}
		}
	}

	/**
	 * Add an order
	 * 
	 * @param array $aOrder 
	 * @return void
	 */
	public function delete()
	{
		$this->notify();
	}
	
	/**
	 * Return the order reference number
	 * 
	 * @return int
	 */
	public function getRef()
	{
		return $this->iOrderRef;
	}
	
	/**
	 * Return the current order status
	 * 
	 * @return int
	 */
	public function getStatus()
	{
		return $this->iStatus;
	}
	
	/**
	 * Update the order status
	 */
	public function updateStatus($iStatus)
	{
		$this->notify();
		// ...
		$this->iStatus = $iStatus;
		// ...
		$this->notify();
	}
}

/**
 * Order status handler, observer that sends an email to secretary
 * if the status of an order changes from shipped to delivered, so the
 * secratary can make a phone call to our customer to ask for his opinion about the service
 * 
 * @package Shop
 */
class OrderStatusHandler implements SplObserver
{
	/**
	 * Previous orderstatus
	 * @var int
	 */
	protected $iPreviousOrderStatus;
	/**
	 * Current orderstatus
	 * @var int
	 */
	protected $iCurrentOrderStatus;
	
	/**
	 * Update, called by the observable object order
	 * 
	 * @param Observable_Interface $oSubject
	 * @param string $sEvent
	 * @param mixed $mData 
	 * @return void
	 */
	public function update(SplSubject $oSubject)
	{
		if(!$oSubject instanceof Order) {
			return;
		}
		if(is_null($this->iPreviousOrderStatus)) {
			$this->iPreviousOrderStatus = $oSubject->getStatus();
		} else {
			$this->iCurrentOrderStatus = $oSubject->getStatus();
			if($this->iPreviousOrderStatus === Order::STATUS_SHIPPED && $this->iCurrentOrderStatus === Order::STATUS_DELIVERED) {
				$sSubject = sprintf('Order number %d is shipped', $oSubject->getRef());
				//mail('secratary@example.com', 'Order number %d is shipped', 'Text');
				echo 'Mail sended to the secratary to help her remember to call our customer for a survey.';
			}
		}
	}
}

$oOrder = new Order(26012011);
$oOrder->attach(new OrderStatusHandler());
$oOrder->updateStatus(Order::STATUS_DELIVERED);
$oOrder->delete();
?>

There are several problems with the implementation above. To most important disadvantage is that we have only one update method in our observer. In this update method we don’t know when and why we are getting notified, just that something happened. We should keep track of everything that happens in the subject. (Or use debug_backtrace… just joking, don’t even think about using it that way ever!).

Taking it a step further, events
Lets take a look at the next example, we will extend the Observer implementation with some an additional parameter for the eventname that occured.

Finishing up, optional data

iOrderRef = $iOrderRef;
		
		// Get order information from the database or something else...
		$this->iStatus = Order::STATUS_SHIPPED;
	}
	
	/**
	 * Attach an observer
	 * 
	 * @param Observer_Interface $oObserver 
	 * @return void
	 */
	public function attachObserver(Observer_Interface $oObserver)
	{
		$sHash = spl_object_hash($oObserver);
		if (isset($this->aObservers[$sHash])) {
			throw new Exception('Observer is already attached');
		}

		$this->aObservers[$sHash] = $oObserver;
	}

	/**
	 * Detach observer
	 * 
	 * @param Observer_Interface $oObserver 
	 * @return void
	 */
	public function detachObserver(Observer_Interface $oObserver)
	{
		$sHash = spl_object_hash($oObserver);
		if (!isset($this->aObservers[$sHash])) {
			throw new Exception('Observer not attached');
		}
		unset($this->aObservers[$sHash]);
	}

	/**
	 * Notify the attached observers
	 * 
	 * @param string $sEvent, name of the event
	 * @param mixed $mData, optional data that is not directly available for the observers
	 * @return void
	 */
	public function notifyObserver($sEvent, $mData=null)
	{
		foreach ($this->aObservers as $oObserver) {
			try {
				$oObserver->update($this, $sEvent, $mData);
			} catch(Exception $e) {

			}
		}
	}

	/**
	 * Add an order
	 * 
	 * @param array $aOrder 
	 * @return void
	 */
	public function add($aOrder = array())
	{
		$this->notifyObserver('onAdd');
	}
	
	/**
	 * Return the order reference number
	 * 
	 * @return int
	 */
	public function getRef()
	{
		return $this->iOrderRef;
	}
	
	/**
	 * Return the current order status
	 * 
	 * @return int
	 */
	public function getStatus()
	{
		return $this->iStatus;
	}
	
	/**
	 * Update the order status
	 */
	public function updateStatus($iStatus)
	{
		$this->notifyObserver('onBeforeUpdateStatus');
		// ...
		$this->iStatus = $iStatus;
		// ...
		$this->notifyObserver('onAfterUpdateStatus');
	}
}

/**
 * Order status handler, observer that sends an email to secretary
 * if the status of an order changes from shipped to delivered, so the
 * secratary can make a phone call to our customer to ask for his opinion about the service
 * 
 * @package Shop
 */
class OrderStatusHandler implements Observer_Interface
{
	protected $iPreviousOrderStatus;
	protected $iCurrentOrderStatus;
	
	/**
	 * Update, called by the observable object order
	 * 
	 * @param Observable_Interface $oObservable
	 * @param string $sEvent
	 * @param mixed $mData 
	 * @return void
	 */
	public function update(Observable_Interface $oObservable, $sEvent, $mData=null)
	{
		if(!$oObservable instanceof Order) {
			return;
		}
		
		switch($sEvent) {
			case 'onBeforeUpdateStatus':
				$this->iPreviousOrderStatus = $oObservable->getStatus();
				return;
			case 'onAfterUpdateStatus':
				$this->iCurrentOrderStatus = $oObservable->getStatus();
				
				if($this->iPreviousOrderStatus === Order::STATUS_SHIPPED && $this->iCurrentOrderStatus === Order::STATUS_DELIVERED) {
					$sSubject = sprintf('Order number %d is shipped', $oObservable->getRef());
					//mail('secratary@example.com', 'Order number %d is shipped', 'Text');
					echo 'Mail sended to the secratary to help her remember to call our customer for a survey.';
				}
		}
	}
}

$oOrder = new Order(26012011);
$oOrder->attachObserver(new OrderStatusHandler());
$oOrder->updateStatus(Order::STATUS_DELIVERED);
$oOrder->add();
?>

Now we are able to take action on different events that occur.

Disadvantages
Although this implementation works quite well there are some drawbacks. One of those drawbacks is that we need to dispatch an event in our framework, if we don’t programmers can’t hook into our application. Triggering events everywhere give us a small performance penalty however I do think this way of working gives the programmers a nice way to hook into your application on those spots that you want them to hook in.

Just for the record
Notice that this code is just an example and can still use some improvements, for example: each observer is initialized even it will maybe never be notified, therefore I suggest to make use of lazy in some cases for loading the objects. There are other systems to hook into an application, more to follow!

Written by Sjoerd Maessen

May 23rd, 2011 at 8:02 pm

Posted in API

Tagged with , , ,

98,458 Responses to 'PHP hook, building hooks in your application'

Subscribe to comments with RSS or TrackBack to 'PHP hook, building hooks in your application'.

  1. LarryArrix

    20 Oct 25 at 6:36 am

  2. In verdict, comprehending the ins and outs of market dynamics, employing robust trading methods,
    and thinking about psychological and emotional variables are critical
    for anyone looking to do well in the trading world.
    By leveraging tools like the CFD Global app, using online educational resources,
    and remaining informed about crucial economic signs such
    as non-farm payroll records, investors can enhance their decision-making processes and exploit on market chances.

  3. I think this is one of the most important info for me. And i
    am glad reading your article. But should remark on some general things, The
    web site style is perfect, the articles is really excellent : D.
    Good job, cheers

  4. Unlike conventional supply exchanges, the forex market operates 24 hours a day, offering
    continuous possibilities for trading various money sets.
    Tools like the forex heatmap can confirm important by aesthetically standing for currency efficiency throughout
    the market range. By assessing this data, traders can create efficient strategies that align with market problems and take advantage of on temporary fluctuations.

    ماركت كوم

    20 Oct 25 at 6:38 am

  5. кракен маркетплейс
    kraken vk2

    JamesDaync

    20 Oct 25 at 6:38 am

  6. купить диплом с занесением в реестр в уфе [url=http://frei-diplom3.ru]http://frei-diplom3.ru[/url] .

    Diplomi_brKt

    20 Oct 25 at 6:39 am

  7. прогнозы на хоккей на сегодня от профессионалов [url=http://www.luchshie-prognozy-na-khokkej8.ru]http://www.luchshie-prognozy-na-khokkej8.ru[/url] .

  8. купить диплом мед колледжа в красноярске [url=www.frei-diplom9.ru]www.frei-diplom9.ru[/url] .

    Diplomi_itea

    20 Oct 25 at 6:42 am

  9. In verdict, understanding the ins and outs of market dynamics, utilizing robust trading strategies, and thinking
    about psychological and psychological elements are critical for anybody looking to succeed in the trading globe.
    By leveraging devices like the CFD Global app, using online academic sources, and remaining educated concerning vital financial indicators such as non-farm payroll records,
    traders can enhance their decision-making processes and exploit on market possibilities.

  10. купить диплом в димитровграде [url=http://www.rudik-diplom7.ru]купить диплом в димитровграде[/url] .

    Diplomi_tuPl

    20 Oct 25 at 6:42 am

  11. В этой публикации мы предлагаем подробные объяснения по актуальным вопросам, чтобы помочь читателям глубже понять их. Четкость и структурированность материала сделают его удобным для усвоения и применения в повседневной жизни.
    Читать дальше – https://www.ibsnsw.org.au/id/galang-dana-alat-kesehatan

    DanielMal

    20 Oct 25 at 6:43 am

  12. проходимые прогнозы на спорт [url=https://prognozy-ot-professionalov4.ru]https://prognozy-ot-professionalov4.ru[/url] .

  13. как купить диплом техникума в казани [url=frei-diplom8.ru]как купить диплом техникума в казани[/url] .

    Diplomi_fcsr

    20 Oct 25 at 6:46 am

  14. купить диплом в хасавюрте [url=www.rudik-diplom15.ru]купить диплом в хасавюрте[/url] .

    Diplomi_duPi

    20 Oct 25 at 6:47 am

  15. купить диплом в кургане занесением в реестр [url=www.frei-diplom3.ru]купить диплом в кургане занесением в реестр[/url] .

    Diplomi_zeKt

    20 Oct 25 at 6:47 am

  16. 1вин теннис ставки [url=http://1win5510.ru/]http://1win5510.ru/[/url]

    1win_uz_pesi

    20 Oct 25 at 6:47 am

  17. successfultradersclub.shop – Feel confident this could become a valuable hub for traders.

    Vonnie Glidden

    20 Oct 25 at 6:49 am

  18. купить диплом в кузнецке [url=http://rudik-diplom6.ru/]http://rudik-diplom6.ru/[/url] .

    Diplomi_sdKr

    20 Oct 25 at 6:49 am

  19. Find the best tools with a comprehensive antidetect browser rating. This crucial information helps digital marketers and e-commerce professionals select a reliable solution for managing multiple online identities securely.

    DouglasJasse

    20 Oct 25 at 6:50 am

  20. Before committing, read detailed antidetect browser reviews. User testimonials and expert analysis provide insights into features like profile isolation, proxy support, and stability for your workflow.

    DouglasJasse

    20 Oct 25 at 6:51 am

  21. clock radio with cd player [url=http://alarm-radio-clocks.com]http://alarm-radio-clocks.com[/url] .

  22. 1вин apk скачать узбекистан [url=https://1win5510.ru]https://1win5510.ru[/url]

    1win_uz_oisi

    20 Oct 25 at 6:51 am

  23. Hi there colleagues, nice piece of writing and nice urging commented here, I am in fact enjoying by these.

  24. купить диплом с проводкой меня [url=http://frei-diplom2.ru]купить диплом с проводкой меня[/url] .

    Diplomi_ixEa

    20 Oct 25 at 6:52 am

  25. купить диплом с занесением в реестр самара [url=https://www.frei-diplom3.ru]https://www.frei-diplom3.ru[/url] .

    Diplomi_mjKt

    20 Oct 25 at 6:52 am

  26. I think this is among the most vital info for me. And i’m glad reading
    your article. But want to remark on some general things,
    The website style is wonderful, the articles is really great : D.
    Good job, cheers

  27. 1вин пополнение через карту [url=http://1win5509.ru/]http://1win5509.ru/[/url]

    1win_uz_fhKt

    20 Oct 25 at 6:53 am

  28. купить диплом техникума легче [url=https://frei-diplom11.ru/]купить диплом техникума легче[/url] .

    Diplomi_nisa

    20 Oct 25 at 6:54 am

  29. купить диплом техникума легко пять плюс [url=https://frei-diplom8.ru]купить диплом техникума легко пять плюс[/url] .

    Diplomi_wcsr

    20 Oct 25 at 6:54 am

  30. Эта информационная заметка содержит увлекательные сведения, которые могут вас удивить! Мы собрали интересные факты, которые сделают вашу жизнь ярче и полнее. Узнайте нечто новое о привычных аспектах повседневности и откройте для себя удивительный мир информации.
    Всё, что нужно знать – https://elegancecleanerslb.com/cideoclipart

    Michaellex

    20 Oct 25 at 6:55 am

  31. 1win uz [url=www.1win5509.ru]www.1win5509.ru[/url]

    1win_uz_lbKt

    20 Oct 25 at 6:56 am

  32. JamesDaync

    20 Oct 25 at 6:56 am

  33. 1win uz [url=www.1win5509.ru]1win uz[/url]

    1win_uz_hkKt

    20 Oct 25 at 6:57 am

  34. купить диплом с реестром отзывы [url=www.frei-diplom2.ru]купить диплом с реестром отзывы[/url] .

    Diplomi_pxEa

    20 Oct 25 at 6:59 am

  35. диплом в колледже купить [url=http://frei-diplom9.ru]диплом в колледже купить[/url] .

    Diplomi_qxea

    20 Oct 25 at 6:59 am

  36. Fascinating blog! Is your theme custom made or did you download it from somewhere?
    A theme like yours with a few simple adjustements would really make
    my blog jump out. Please let me know where you got your design. Thanks
    a lot

    dewascatter login

    20 Oct 25 at 7:00 am

  37. Explore UndressWith AI, a leading tool that uses artificial intelligence
    to digitally undress photos. Learn about its features, ethical use, technology, and
    responsible alternatives to safely experiment with AI-powered
    photo editing in creative projects.

    undress AI

    20 Oct 25 at 7:00 am

  38. В этом интересном тексте собраны обширные сведения, которые помогут вам понять различные аспекты обсуждаемой темы. Мы разбираем детали и факты, делая акцент на важности каждого элемента. Не упустите возможность расширить свои знания и взглянуть на мир по-новому!
    Открой скрытое – https://www.logopedtorbica.com/2021/09/08/vrste-praksija

    Charlesbopay

    20 Oct 25 at 7:00 am

  39. Code promo pour 1xBet : utilisez-le une fois lors de l’inscription et obtenez un bonus de 100% pour l’inscription jusqu’a 130€. Renforcez votre solde facilement en placant des paris avec un multiplicateur de cinq fois. Le code bonus est valide tout au long de l’annee 2026. Pour activer ce code, rechargez votre compte a partir de 1€. Vous pouvez trouver le code promo 1xbet sur ce lien — Code Promo 1xbet Bonus De Bienvenue. Le code promo 1xBet aujourd’hui est disponible pour les joueurs du Cameroun, du Senegal et de la Cote d’Ivoire. Avec le 1xBet code promo bonus, obtenez jusqu’a 130€ de bonus promotionnel du code 1xBet. Ne manquez pas le dernier code promo 1xBet 2026 pour les paris sportifs et les jeux de casino.

    Marvinspaft

    20 Oct 25 at 7:00 am

  40. купить диплом в крыму [url=https://rudik-diplom4.ru]купить диплом в крыму[/url] .

    Diplomi_mlOr

    20 Oct 25 at 7:01 am

  41. Wheel Yoga

    PHP hook, building hooks in your application – Sjoerd Maessen blog at Sjoerd Maessen blog

    Wheel Yoga

    20 Oct 25 at 7:01 am

  42. купить диплом массажиста [url=http://www.rudik-diplom14.ru]купить диплом массажиста[/url] .

    Diplomi_psea

    20 Oct 25 at 7:01 am

  43. новости киберспорта [url=sportivnye-novosti-2.ru]новости киберспорта[/url] .

  44. Hey there! Someone in my Myspace group shared this website with us so I came to look it over.
    I’m definitely loving the information. I’m book-marking and will be tweeting this to my followers!
    Fantastic blog and outstanding style and design.

    site

    20 Oct 25 at 7:04 am

  45. 1win uz [url=1win5510.ru]1win5510.ru[/url]

    1win_uz_absi

    20 Oct 25 at 7:04 am

  46. купить диплом в уфе с реестром [url=https://www.frei-diplom2.ru]https://www.frei-diplom2.ru[/url] .

    Diplomi_cxEa

    20 Oct 25 at 7:04 am

  47. I blog often and I truly thank you for your content.
    Your article has really peaked my interest. I will book
    mark your website and keep checking for new information about once per week.
    I subscribed to your RSS feed as well.

    best drugs

    20 Oct 25 at 7:04 am

  48. доставка алкоголя ночью на дом [url=https://alcoygoloc.ru/]https://alcoygoloc.ru/[/url] .

  49. The rise of social trading platforms has actually
    transformed exactly how traders engage with one another.
    The emotional part in trading is frequently
    overlooked; however, social responsibility can favorably impact an investor’s performance by offering motivation and assistance in navigating the rollercoaster of monetary
    markets.

    cfd global app

    20 Oct 25 at 7:05 am

  50. Amo a atmosfera de BETesporte Casino, proporciona uma aventura competitiva. A variedade de titulos e impressionante, suportando jogos adaptados para criptos. 100% ate R$600 + apostas gratis. O suporte ao cliente e de elite, oferecendo respostas claras. Os ganhos chegam sem demora, contudo recompensas extras seriam um hat-trick. No fim, BETesporte Casino oferece uma experiencia inesquecivel para entusiastas de jogos modernos ! Adicionalmente o site e veloz e envolvente, facilita uma imersao total. Muito atrativo os torneios regulares para rivalidade, proporciona vantagens personalizadas.
    Obter os detalhes|

    FutebolFogoM4zef

    20 Oct 25 at 7:05 am

Leave a Reply