Path

ez components / documentation / api reference / latest / execution


eZ Components latest

Execution: ezcExecution

[ Tutorial ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

Class: ezcExecution

Class for handling fatal errors [source]
This class allows you to invoke a handler whenever a fatal error occurs, or when an uncatched exception happens. You can specify which callback function to use and signal whether your application cleanly exited.
Example:
 1.  <?php
 2.  class myExecutionHandler extends ezcExecutionBasicErrorHandler
 3.  {
 4.      public static function onErrorException $exception null )
 5.      {
 6.          echo "Error!\n";
 7.          // If you want, you can use the parent's onError method, but that
 8.          // will only show a standard message.
 9.          parent::onError$exception );
10.      }
11.  }
12.  
13.  ezcExecution::init'myExecutionHandler' );
14.  
15.  // ....
16.  
16.  
17.  ezcExecution::cleanExit();
18.  ?>

Method Summary

public static void cleanExit( )
Marks the current application as cleanly-exited.
public static void exceptionCallbackHandler( $e )
Handler for uncaught exceptions.
public static void init( $callbackClassName )
Initializes the ezcExecution environment.
public static void reset( )
Resets the ezcExecution environment.
public static void shutdownCallbackHandler( )
Shutdown handler

Methods

cleanExit

void cleanExit( )
Marks the current application as cleanly-exited.
With this method you signal the ezcExecution environment that your application ended without errors. This is usually done just before you reach the end of your script, or just before you call exit() or die().

Throws

ClassDescription
ezcExecutionNotInitializedException if the environment was not yet initialized.

exceptionCallbackHandler

void exceptionCallbackHandler( $e )
Handler for uncaught exceptions.
The ezcExecution environment installs this method as handler for uncaught exceptions and will be called when one is found. This method's only function is to call the ::onError() static method of the error handler set with the init() method. It passes along the uncaught exception to this method.
This method has to be public otherwise PHP can not call it, but you should never call this method yourself.

Parameters

Name Type Description
$e Exception  

init

void init( string $callbackClassName )
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.

Parameters

Name Type Description
$callbackClassName string  

Throws

ClassDescription
ezcExecutionInvalidCallbackException if an unknown callback class was passed.
ezcExecutionWrongClassException if an invalid callback class was passed.
ezcExecutionAlreadyInitializedException if the environment was already initialized.

reset

void reset( )
Resets the ezcExecution environment.
With this function you reset the environment. Usually this method should not be used, but in the cases when you want to restart the environment this is the method to use. It also takes care of restoring the user defined uncaught exception handler, but it can not undo the registered shutdown handler as PHP doesn't provide that functionality.

shutdownCallbackHandler

void shutdownCallbackHandler( )
Shutdown handler
The ezcExecution environment installs this method as general shutdown handler. This method's only function is to call the ::onError() static method of the error handler set with the init() method.

Last updated: Mon, 10 Nov 2008