File tree Expand file tree Collapse file tree 7 files changed +79
-17
lines changed
Expand file tree Collapse file tree 7 files changed +79
-17
lines changed Original file line number Diff line number Diff line change @@ -11,8 +11,5 @@ indent_size = 4
1111trim_trailing_whitespace = true
1212insert_final_newline = true
1313
14- [* .md ]
15- trim_trailing_whitespace = false
16-
1714[* .yml ]
1815indent_size = 2
Original file line number Diff line number Diff line change 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 /
Original file line number Diff line number Diff line change 11build :
2+ environment :
3+ php :
4+ version : ' 8.0'
5+ ini :
6+ ' xdebug.mode ' : ' coverage'
27 nodes :
38 analysis :
49 tests :
Original file line number Diff line number Diff line change 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 */
187187class Entry
Original file line number Diff line number Diff line change 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" : {
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 66 * Import classes
77 */
88use Arus \Doctrine \Bridge \ManagerRegistry ;
9+ use Arus \Doctrine \Bridge \SQLLogger ;
910use DI \Container ;
1011use DI \ContainerBuilder ;
12+ use Monolog \Logger ;
1113use Symfony \Component \Validator \ContainerConstraintValidatorFactory ;
1214use Symfony \Component \Validator \Validation ;
1315
1416/**
1517 * Import functions
1618 */
1719use function DI \autowire ;
20+ use function DI \create ;
21+ use function DI \get ;
1822use 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 ' => [
You can’t perform that action at this time.
0 commit comments