Services are libraries of functions which you may require in may different locations. For the purposes of documentation services are synonymous with libraries; however, generally I consider there to be a subtle difference in interpretation. There are several services packaged with the InterJinn framework such as the Database System, the Session System, and the FormJinn Framework. It is expected that you will use these services often. To make your own services usable from within your components, or within other services, you must declare them. Declaring services is shown below.
Each service must be declared in the array defined by this
global variable. The key of the entry
represents the name of the class to instantiate for the service and the
value defines the path to the PHP source file
in which the class exists. If you are overriding a core service then you also
register the replacement service here. If the path to the source code is
prefixed by a forward slash (/) then the path
will be considered relative to the root of the filesystem. If the path is
prefixed by three forward slashes (///) then it
will be considered relative to the coreRoot
path. Alternatively if the path is prefixed by two forward slashes
(//) or none at all then it will be considered
relative to the codeRoot path.
$GLOBALS['interJinn']['services'] = array
(
'MyOwnDatabaseService' => 'InterJinn/services/postgreSql.inc',
);
The above example decalres a database service for a Postgres database server. InterJinn does not actually come with support for postgres; however, this example illustrates how to easily add support. Now that the appropriate source code has been registered, you must now create any aliases that you will want to use to refer to the service when loading it.
Aliases are convenient shorthand names for accessing any
services. As a matter of a fact you cannot access the service except by one of
its defined aliases. If you are replacing a core service then you must ensure
that any aliases to the core service are aliased to your service in this
structure. The format of the alias entry is the key refers to the alias name and the value refers to a key in the $GLOBALS['interJinn']['services'] array.
$GLOBALS['interJinn']['coreDynamicResourceAliases'] = array
(
'dbManager' => 'MyOwnDatabaseService',
);
Since it is a very likely event that you will want to replace a core service at some point (especially to add support for a non MySQL database service), the following lists all of the core services and their aliases so that you will know what to override in your declarations:
$GLOBALS['interJinn']['services'] = array
(
//////////////////////////////////////////////////////////
//
// Core services.
//
'JinnDatabaseManager' =>
'///Core/databaseManager.inc',
'JinnException' =>
'///Core/exception.inc',
'JinnCacheManager' =>
'///Core/cacheManager.inc',
'JinnProfileManager' =>
'///Core/profileManager.inc',
'JinnSessionManager' =>
'///Core/sessionManager.inc',
'JinnPropertyManager' =>
'///Core/propertyManager.inc',
'JinnUrlPool' =>
'///Core/libraries/url/urlPool.inc',
'JinnAccumulatorPool' =>
'///Core/libraries/accumulator/accumulatorPool.inc',
'JinnDummyClass' =>
'///Core/dummyClass.inc',
//////////////////////////////////////////////////////////
//
// Core libraries.
//
'JinnLibraryFormJinn' =>
'///Core/libraries/formJinn/formJinn.inc',
'JinnLibraryWidgetJinn' =>
'///Core/libraries/formJinn/widgetJinn.inc',
'JinnLibraryInputProcessor' =>
'///Core/libraries/formJinn/inputProcessor.inc',
'JinnLibraryHtmlFont' =>
'///Core/libraries/html/html.inc',
'JinnLibraryHtmlTableTD' =>
'///Core/libraries/html/html.inc',
'JinnLibraryHtmlTableTD' =>
'///Core/libraries/html/html.inc',
'JinnLibraryHtmlTableTR' =>
'///Core/libraries/html/html.inc',
'JinnLibraryHtmlTable' =>
'///Core/libraries/html/html.inc',
'JinnLibraryHtmlSpacer' =>
'///Core/libraries/html/html.inc',
'JinnLibraryHtmlRollover' =>
'///Core/libraries/html/html.inc',
'JinnLibraryHtmlBox' =>
'///Core/libraries/html/html.inc',
'JinnTerminal' =>
'///Core/libraries/terminal/terminal.inc',
'JinnAnsiColour' =>
'///Core/libraries/ansiColour/ansiColour.inc',
'JinnUtility' =>
'///Core/libraries/utility/utility.inc',
'JinnLanguageAgent' =>
'///Core/libraries/language/languageAgent.inc',
//////////////////////////////////////////////////////////
//
// Template management system.
//
'JinnLibraryPatternManager' =>
'///Core/libraries/templateJinn/patternManager.inc',
'JinnLibraryTemplateManager' =>
'///Core/libraries/templateJinn/templateManager.inc',
'JinnLibraryContentManager' =>
'///Core/libraries/templateJinn/contentManager.inc',
'JinnLibraryParserRoutines' =>
'///Core/libraries/templateJinn/parserRoutines.inc',
'JinnLibrarySynchronizer' =>
'///Core/libraries/templateJinn/synchronizer.inc',
);
$GLOBALS['interJinn']['serviceAliases'] = array
(
'dbManager' => 'JinnDatabaseManager',
'exception' => 'JinnException',
'cacheManager' => 'JinnCacheManager',
'profileManager' => 'JinnProfileManager',
'sessionManager' => 'JinnSessionManager',
'propertyManager' => 'JinnPropertyManager',
'accManager' => 'JinnAccumulatorManager',
'urlManager' => 'JinnUrlManager',
'dummy' => 'JinnDummyClass',
'formJinn' => 'JinnLibraryFormJinn',
'widgetJinn' => 'JinnLibraryWidgetJinn',
'inputProcessor' => 'JinnLibraryInputProcessor',
'htmlFont' => 'JinnLibraryHtmlFont',
'htmlCell' => 'JinnLibraryHtmlTableTD',
'htmlTd' => 'JinnLibraryHtmlTableTD',
'htmlRow' => 'JinnLibraryHtmlTableTR',
'htmlTable' => 'JinnLibraryHtmlTable',
'htmlSpacer' => 'JinnLibraryHtmlSpacer',
'htmlRollover' => 'JinnLibraryHtmlRollover',
'htmlBox' => 'JinnLibraryHtmlBox',
'ncurses' => 'JinnTerminal',
'ansiColour' => 'JinnAnsiColour',
'ansiColor' => 'JinnAnsiColour',
'utils' => 'JinnUtility',
'languageAgent' => 'JinnLanguageAgent',
//////////////////////////////////////////////////////////////////
//
// Template management aliases.
//
'patternManager' => 'JinnLibraryPatternManager',
'templateManager' => 'JinnLibraryTemplateManager',
'contentManager' => 'JinnLibraryContentManager',
'jinnParser' => 'JinnLibraryParserRoutines',
'jinnSynch' => 'JinnLibrarySynchronizer',
);