<?php
class AOWP_RequestAroundManageAspect extends AOWP_PerJoinPointAspect {
	
	private static $_IN_PROCEED = false;
	
	public function __construct() {
		$throwRequestAroundEndExeptionAdvice = new AOWP_BeforeAdvice();
		$exitOrDieFunctionCallPC = new AOWP_FunctionCallPointcut('^exit$|^die$');
		$throwRequestAroundEndExeptionAdvice->setPointcut($exitOrDieFunctionCallPC);
		$throwRequestAroundEndExeptionAdvice->setAdviceBody('_throwRequestAroundEndException');
		$this->addAdvice($throwRequestAroundEndExeptionAdvice);
	}
	
	protected function _throwRequestAroundEndException() {
		if (AOWP_RequestAroundManageAspect::$_IN_PROCEED) {
			throw new AOWP_RequestAroundEndException();
		}
	}
	
	public static function inRequestProceed() {
		AOWP_RequestAroundManageAspect::$_IN_PROCEED = true;
	}
	public static function outRequestProceed() {
		AOWP_RequestAroundManageAspect::$_IN_PROCEED = false;
	}
}
?>