====== EPP-DRS API Manual ======
#intro_start#
EPP-DRS exposes mature and robust APIs for developers who wish to
* develop their own modules,
* integrate EPP-DRS with other application and services,
* add custom handlers to various EPP-DRS events\\
Currently, you are able to create two types of custom modules: Payment and Registry.
#intro_end#
#toc#
===== API Reference =====
The latest EPP-DRS API reference, generated with PHPDoc is available [[http://epp-drs.com/docs/phpdoc/|here]]
===== Payment module API (PAPI) =====
Payment module is a bridge between EPP-DRS and payment proccessing service. \\
See [[EPP-DRS Payment Modules API]] for more information.
===== Registry Module API (RAPI) =====
Registry module communicate with a registry or SRS to register, renew domains, create contacts and hosts etc.\\
See [[EPP-DRS Registry Modules API]] for more information.
===== Event Handlers =====
To help you integrate EPP-DRS with your existing environment, we created event handlers.
Event handlers allow you to react to different EPP-DRS internal events.
For example, you can execute your own PHP code when new client is created or before domain is created or when new invoice is issued.
See [[Event Handlers]] for more information.
===== Object model and common techniques =====
Sections below describe object model and programming techniques that are common to all EPP-DRS APIs.
==== Logging and debugging ====
To log a message to system log, use the following code:
Log::Log($message, $severity);
Possible values for ''$severity'' are ''E_ERROR, E_WARNING, E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE''.\\
Depending on severity, log entries are displayed differently in log viewer.\\
In case of E_ERROR, log entry will also contain execution backtrace.
==== Throwing Exceptions ====
You can either throw Exception or CustomException. These are actually equal, because CustomException is thrown on all uncaught exceptions via set_exception_handler().\\
Exception will add a record to log with severity ''E_USER_ERROR'' and draw ''templates/exception.tpl'' template.\\
When thrown in Control panels (''CONTEXTS::$APPCONTEXT = APPCONTEXT::REGISTRANT_CP'' or ''CONTEXTS::$APPCONTEXT = APPCONTEXT::REGISTRAR_CP''), it will draw ''templates/exception_cp.tpl'' template.\\
if (false == true)
throw new CustomException("This will appear inside grey box surrounded by red border.");
==== Accessing global constants and objects ====
=== CONFIG ===
System configuration parameters are taken from database, config.ini. Some parameters are hard-coded.\\
You can access most of them via global [[http://epp-drs.com/docs/phpdoc/Common/CONFIG.html|CONFIG]] enumerator.
Here is a sample:
// $currency will be assigned a value of current currency symbol.
$currency = CONFIG::$CURRENCY;
=== CONTEXTS:APPCONTEXT ===
You can use CONTEXTS::APPCONTEXT constant to retreive current application context in your code.\\
The value is one of [[http://epp-drs.com/docs/phpdoc/Common/APPCONTEXT.html]] members.
Here is a sample:
switch (CONTEXTS:APPCONTEXT)
{
case APPCONTEXT::ORDERWIZARD :
echo("We are in order wizard");
break;
case APPCONTEXT::REGISTRANT_CP :
echo ("We are in /client");
break;
case APPCONTEXT::REGISTRAR_CP :
echo ("We are in /admin");
break;
default:
echo ("Context not defined yet");
break;
}
===== Limitations =====
The following functions are not allowed in module code:
* apd_*()
* xdebug_*()
* eval()
* var_dump()
* print_r()
* classkit_*()
* create_function()
* call_user_func()
The following class names are not allowed in module code:
* Reflection*()