Skip to content

Commit d2d892b

Browse files
authored
Merge pull request #13 from autorusltd/release/v1.18.0
v1.18.0
2 parents 7f11257 + 9f060d0 commit d2d892b

File tree

7 files changed

+79
-17
lines changed

7 files changed

+79
-17
lines changed

.editorconfig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,5 @@ indent_size = 4
1111
trim_trailing_whitespace = true
1212
insert_final_newline = true
1313

14-
[*.md]
15-
trim_trailing_whitespace = false
16-
1714
[*.yml]
1815
indent_size = 2

.gitignore

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
.php_cs.cache
2-
.phpunit.result.cache
3-
composer.lock
4-
coverage.xml
5-
phpbench.json
6-
phpcs.xml
7-
phpunit.xml
8-
tests/db/*.sqlite
9-
vendor/
1+
/.php_cs.cache
2+
/.phpunit.result.cache
3+
/composer.lock
4+
/coverage.xml
5+
/phpbench.json
6+
/phpcs.xml
7+
/phpunit.xml
8+
/tests/db/*.sqlite
9+
/vendor/

.scrutinizer.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
build:
2+
environment:
3+
php:
4+
version: '8.0'
5+
ini:
6+
'xdebug.mode': 'coverage'
27
nodes:
38
analysis:
49
tests:

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
## Installation
1313

1414
```bash
15-
composer require 'arus/doctrine-bridge:^1.10'
15+
composer require 'arus/doctrine-bridge:^1.18'
1616
```
1717

1818
## Examples of using
@@ -177,11 +177,11 @@ use Arus\Doctrine\Bridge\Validator\Constraint\UniqueEntity;
177177

178178
/**
179179
* @UniqueEntity({"foo"})
180-
*
180+
*
181181
* @UniqueEntity({"bar", "baz"})
182-
*
182+
*
183183
* @UniqueEntity({"qux"}, atPath="customPropertyPath")
184-
*
184+
*
185185
* @UniqueEntity({"quux"}, message="The value {{ value }} already exists!")
186186
*/
187187
class Entry

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"php-di/php-di": "^6.0",
3131
"doctrine/orm": "^2.7",
3232
"doctrine/migrations": "^2.2",
33-
"symfony/validator": "^5.0"
33+
"symfony/validator": "^5.0",
34+
"monolog/monolog": "^2.0"
3435
},
3536
"autoload": {
3637
"psr-4": {

src/SQLLogger.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Arus\Doctrine\Bridge;
4+
5+
/**
6+
* Import classes
7+
*/
8+
use Doctrine\DBAL\Logging\DebugStack;
9+
use Psr\Log\LoggerInterface;
10+
11+
/**
12+
* Import functions
13+
*/
14+
use function array_pop;
15+
use function sprintf;
16+
17+
/**
18+
* SQLLogger
19+
*/
20+
final class SQLLogger extends DebugStack
21+
{
22+
23+
/**
24+
* @var LoggerInterface
25+
*/
26+
private $logger;
27+
28+
/**
29+
* @param LoggerInterface $logger
30+
*/
31+
public function __construct(LoggerInterface $logger)
32+
{
33+
$this->logger = $logger;
34+
}
35+
36+
/**
37+
* {@inheritDoc}
38+
*/
39+
public function stopQuery()
40+
{
41+
parent::stopQuery();
42+
43+
$report = array_pop($this->queries);
44+
45+
$this->logger->debug(sprintf(
46+
'[%2.3fµ] %s',
47+
$report['executionMS'] * 1000,
48+
$report['sql']
49+
), [
50+
'params' => $report['params'],
51+
'types' => $report['types'],
52+
]);
53+
}
54+
}

tests/Fixture/ContainerAwareTrait.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,19 @@
66
* Import classes
77
*/
88
use Arus\Doctrine\Bridge\ManagerRegistry;
9+
use Arus\Doctrine\Bridge\SQLLogger;
910
use DI\Container;
1011
use DI\ContainerBuilder;
12+
use Monolog\Logger;
1113
use Symfony\Component\Validator\ContainerConstraintValidatorFactory;
1214
use Symfony\Component\Validator\Validation;
1315

1416
/**
1517
* Import functions
1618
*/
1719
use function DI\autowire;
20+
use function DI\create;
21+
use function DI\get;
1822
use function DI\factory;
1923

2024
/**
@@ -54,6 +58,7 @@ private function getContainer() : Container
5458
'types' => [
5559
Example1DbalType::NAME => Example1DbalType::class,
5660
],
61+
'sql_logger' => new SQLLogger(new Logger('test')),
5762
],
5863
'bar' => [
5964
'connection' => [

0 commit comments

Comments
 (0)