Skip to content

Commit

Permalink
add connection established event
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jan 27, 2023
1 parent cf825bb commit f850d99
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Illuminate/Database/DatabaseManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Doctrine\DBAL\Types\Type;
use Illuminate\Database\Connectors\ConnectionFactory;
use Illuminate\Database\Events\ConnectionEstablished;
use Illuminate\Support\Arr;
use Illuminate\Support\ConfigurationUrlParser;
use Illuminate\Support\Str;
Expand Down Expand Up @@ -99,6 +100,12 @@ public function connection($name = null)
$this->connections[$name] = $this->configure(
$this->makeConnection($database), $type
);

if ($this->app->bound('events')) {
$this->app['events']->dispatch(
new ConnectionEstablished($this->connections[$name])
);
}
}

return $this->connections[$name];
Expand Down
8 changes: 8 additions & 0 deletions src/Illuminate/Database/Events/ConnectionEstablished.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Illuminate\Database\Events;

class ConnectionEstablished extends ConnectionEvent
{
//
}

0 comments on commit f850d99

Please sign in to comment.