[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Part of the Joomla Framework Database Package 4 * 5 * @copyright Copyright (C) 2005 - 2021 Open Source Matters, Inc. All rights reserved. 6 * @license GNU General Public License version 2 or later; see LICENSE 7 */ 8 9 namespace Joomla\Database\Service; 10 11 use Joomla\Database\DatabaseDriver; 12 use Joomla\Database\DatabaseFactory; 13 use Joomla\Database\DatabaseInterface; 14 use Joomla\DI\Container; 15 use Joomla\DI\ServiceProviderInterface; 16 17 /** 18 * Database service provider 19 * 20 * @since 2.0.0 21 */ 22 class DatabaseProvider implements ServiceProviderInterface 23 { 24 /** 25 * Registers the service provider with a DI container. 26 * 27 * @param Container $container The DI container. 28 * 29 * @return void 30 * 31 * @since 2.0.0 32 */ 33 public function register(Container $container) 34 { 35 $container->alias(DatabaseInterface::class, DatabaseDriver::class) 36 ->share( 37 DatabaseDriver::class, 38 function (Container $container) 39 { 40 /** @var \Joomla\Registry\Registry $config */ 41 $config = $container->get('config'); 42 $options = (array) $config->get('database'); 43 44 return $container->get(DatabaseFactory::class)->getDriver($options['driver'], $options); 45 } 46 ); 47 48 $container->share( 49 DatabaseFactory::class, 50 function (Container $container) 51 { 52 return new DatabaseFactory; 53 } 54 ); 55 } 56 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |