Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

lazy.php
Go to the documentation of this file.
1 <?php
12 class ezpRestDbConfig implements ezcBaseConfigurationInitializer
13 {
14 public static function configureObject( $instance )
15 {
16 //Ignoring $instance
17 $dsn = self::lazyDbHelper();
18 return ezcDbFactory::create( $dsn );
19 }
20
21 protected static function lazyDbHelper()
22 {
23 $dbMapping = array( 'ezmysqli' => 'mysql',
24 'ezmysql' => 'mysql',
25 'mysql' => 'mysql',
26 'mysqli' => 'mysql',
27 'pgsql' => 'pgsql',
28 'postgresql' => 'pgsql',
29 'ezpostgresql' => 'pgsql',
30 'ezoracle' => 'oracle',
31 'oracle' => 'oracle' );
32
33 $ini = eZINI::instance();
34 list( $dbType, $dbHost, $dbPort, $dbUser, $dbPass, $dbName ) =
35 $ini->variableMulti( 'DatabaseSettings',
36 array( 'DatabaseImplementation', 'Server', 'Port',
37 'User', 'Password', 'Database',
38 )
39 );
40
41 if ( !isset( $dbMapping[$dbType] ) )
42 {
43 // @TODO: Add a proper exception type here.
44 throw new Exception( "Unknown / unmapped DB type '$dbType'" );
45 }
46
47 $dbType = $dbMapping[$dbType];
48
49 $dsnHost = $dbHost . ( $dbPort != '' ? ":$dbPort" : '' );
50 $dsnAuth = $dbUser . ( $dbPass != '' ? ":$dbPass" : '' );
51 $dsn = "{$dbType}://{$dbUser}:{$dbPass}@{$dsnHost}/{$dbName}";
52
53 return $dsn;
54 }
55 }
56 ezcBaseInit::setCallback( 'ezcInitDatabaseInstance', 'ezpRestDbConfig' );
57
58 class ezpRestPoConfig implements ezcBaseConfigurationInitializer
59 {
60 public static function configureObject( $instance )
61 {
62 return new ezcPersistentSession( ezcDbInstance::get(),
63 new ezcPersistentMultiManager( array(
64 new ezcPersistentCodeManager( 'kernel/private/rest/classes/po_maps/' ),
65 new ezcPersistentCodeManager( 'kernel/private/oauth/classes/persistentobjects/' )
66 ))
67 );
68 }
69 }
70 ezcBaseInit::setCallback( 'ezcInitPersistentSessionInstance', 'ezpRestPoConfig' );
71
72 ?>
$ini
$ini
Definition: classes/admin/linklist.php:64
ezpRestDbConfig
Definition: lazy.php:13
ezpRestDbConfig\configureObject
static configureObject( $instance)
Definition: lazy.php:14
ezpRestDbConfig\lazyDbHelper
static lazyDbHelper()
Definition: lazy.php:21
ezpRestPoConfig
Definition: lazy.php:59
ezpRestPoConfig\configureObject
static configureObject( $instance)
Definition: lazy.php:60
$instance
$instance
Definition: orderedit.php:667
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.