-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove code duplication
- Loading branch information
Showing
4 changed files
with
56 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Crud\Traits; | ||
|
||
use Cake\Datasource\ConnectionManager; | ||
|
||
/** | ||
* QueryLogTrait | ||
* | ||
* Licensed under The MIT License | ||
* For full copyright and license information, please see the LICENSE.txt | ||
*/ | ||
trait QueryLogTrait | ||
{ | ||
/** | ||
* Get the query logs | ||
* | ||
* @return array | ||
*/ | ||
protected function _getQueryLog(): array | ||
{ | ||
$queryLog = []; | ||
|
||
foreach (ConnectionManager::configured() as $source) { | ||
$driver = ConnectionManager::get($source)->getDriver(); | ||
if (!method_exists($driver, 'getLogger')) { | ||
continue; | ||
} | ||
|
||
$logger = $driver->getLogger(); | ||
if ($logger && method_exists($logger, 'getLogs')) { | ||
/** @var \Crud\Log\QueryLogger $logger */ | ||
$queryLog[$source] = $logger->getLogs(); | ||
} | ||
} | ||
|
||
return $queryLog; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters