示例#1
0
 /**
  * Initializes the ezcExecution environment.
  *
  * With this method you initialize the ezcExecution environment. You need
  * to specify a class name $callBackClassName that will be used to call the
  * onError() method on in case of an error. The class name that you
  * pass should implement the ezcExecutionErrorHandler interface. This
  * method takes care of registering the uncaught exception and shutdown
  * handlers. 
  *
  * @throws ezcExecutionInvalidCallbackException if an unknown callback
  *         class was passed.
  * @throws ezcExecutionWrongClassException if an invalid callback class was
  *         passed.
  * @throws ezcExecutionAlreadyInitializedException if the environment was
  *         already initialized.
  *
  * @param string $callbackClassName 
  * @return void
  */
 public static function init($callbackClassName)
 {
     // Check if the passed classname actually exists
     if (!ezcBaseFeatures::classExists($callbackClassName, true)) {
         throw new ezcExecutionInvalidCallbackException($callbackClassName);
     }
     // Check if the passed classname actually implements the interface. We
     // have to do that with reflection here unfortunately since we only
     // have the classname and not an object.
     $interfaceClass = new ReflectionClass('ezcExecutionErrorHandler');
     $handlerClass = new ReflectionClass($callbackClassName);
     if (!$handlerClass->isSubclassOf($interfaceClass)) {
         throw new ezcExecutionWrongClassException($callbackClassName);
     }
     // Check if it was already initialized once
     if (self::$isInitialized == true) {
         throw new ezcExecutionAlreadyInitializedException();
     }
     // Install shutdown handler and exception handler
     set_exception_handler(array('ezcExecution', 'exceptionCallbackHandler'));
     if (!self::$shutdownHandlerRegistered) {
         register_shutdown_function(array('ezcExecution', 'shutdownCallbackHandler'));
     }
     self::$callbackClassName = $callbackClassName;
     self::$isInitialized = true;
     self::$cleanExit = false;
     self::$shutdownHandlerRegistered = true;
 }
示例#2
0
 /**
  * Initializes the ezcExecution environment.
  *
  * With this method you initialize the ezcExecution environment. You need
  * to specify a class name $callBackClassName that will be used to call the
  * onError() method on in case of an error. The class name that you
  * pass should implement the ezcExecutionErrorHandler interface. This
  * method takes care of registering the uncaught exception and shutdown
  * handlers. 
  *
  * @throws ezcExecutionInvalidCallbackException if an unknown callback
  *         class was passed.
  * @throws ezcExecutionWrongClassException if an invalid callback class was
  *         passed.
  * @throws ezcExecutionAlreadyInitializedException if the environment was
  *         already initialized.
  *
  * @param string $callbackClassName 
  * @return void
  */
 public static function init($callbackClassName)
 {
     // Check if the passed classname actually exists
     if (!ezcBaseFeatures::classExists($callbackClassName, true)) {
         throw new ezcExecutionInvalidCallbackException($callbackClassName);
     }
     // Check if the passed classname actually implements the interface.
     if (!in_array('ezcExecutionErrorHandler', class_implements($callbackClassName))) {
         throw new ezcExecutionWrongClassException($callbackClassName);
     }
     // Check if it was already initialized once
     if (self::$isInitialized == true) {
         throw new ezcExecutionAlreadyInitializedException();
     }
     // Install shutdown handler and exception handler
     set_exception_handler(array('ezcExecution', 'exceptionCallbackHandler'));
     if (!self::$shutdownHandlerRegistered) {
         register_shutdown_function(array('ezcExecution', 'shutdownCallbackHandler'));
     }
     self::$callbackClassName = $callbackClassName;
     self::$isInitialized = true;
     self::$cleanExit = false;
     self::$shutdownHandlerRegistered = true;
 }