| @@ 8-34 (lines=27) @@ | ||
| 5 | use Aura\Sql\ExtendedPdo; |
|
| 6 | use League\Container\ServiceProvider; |
|
| 7 | ||
| 8 | class DatabaseDataServiceProvider extends ServiceProvider |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * @var array |
|
| 12 | */ |
|
| 13 | protected $provides = [ |
|
| 14 | 'Database\Data' |
|
| 15 | ]; |
|
| 16 | ||
| 17 | /** |
|
| 18 | * {@inheritdoc} |
|
| 19 | */ |
|
| 20 | public function register() |
|
| 21 | { |
|
| 22 | $this->getContainer()->singleton('Database\Data', function () { |
|
| 23 | $config = $this->getContainer()->get('config')['database_data']; |
|
| 24 | ||
| 25 | $pdo = new ExtendedPdo( |
|
| 26 | "mysql:host={$config['host']};dbname={$config['schema']}", |
|
| 27 | $config['user'], |
|
| 28 | $config['password'] |
|
| 29 | ); |
|
| 30 | ||
| 31 | return $pdo; |
|
| 32 | }); |
|
| 33 | } |
|
| 34 | } |
|
| 35 | ||
| @@ 8-34 (lines=27) @@ | ||
| 5 | use Aura\Sql\ExtendedPdo; |
|
| 6 | use League\Container\ServiceProvider; |
|
| 7 | ||
| 8 | class DatabaseServiceProvider extends ServiceProvider |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * @var array |
|
| 12 | */ |
|
| 13 | protected $provides = [ |
|
| 14 | 'Database' |
|
| 15 | ]; |
|
| 16 | ||
| 17 | /** |
|
| 18 | * {@inheritdoc} |
|
| 19 | */ |
|
| 20 | public function register() |
|
| 21 | { |
|
| 22 | $this->getContainer()->singleton('Database', function () { |
|
| 23 | $config = $this->getContainer()->get('config')['database']; |
|
| 24 | ||
| 25 | $pdo = new ExtendedPdo( |
|
| 26 | "mysql:host={$config['host']};dbname={$config['schema']}", |
|
| 27 | $config['user'], |
|
| 28 | $config['password'] |
|
| 29 | ); |
|
| 30 | ||
| 31 | return $pdo; |
|
| 32 | }); |
|
| 33 | } |
|
| 34 | } |
|
| 35 | ||