Skip to content

Commit

Permalink
Merge pull request #13 from autorusltd/release/v1.18.0
Browse files Browse the repository at this point in the history
v1.18.0
  • Loading branch information
fenric authored Feb 7, 2021
2 parents 7f11257 + 9f060d0 commit d2d892b
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 17 deletions.
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,5 @@ indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
18 changes: 9 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.php_cs.cache
.phpunit.result.cache
composer.lock
coverage.xml
phpbench.json
phpcs.xml
phpunit.xml
tests/db/*.sqlite
vendor/
/.php_cs.cache
/.phpunit.result.cache
/composer.lock
/coverage.xml
/phpbench.json
/phpcs.xml
/phpunit.xml
/tests/db/*.sqlite
/vendor/
5 changes: 5 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
build:
environment:
php:
version: '8.0'
ini:
'xdebug.mode': 'coverage'
nodes:
analysis:
tests:
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
## Installation

```bash
composer require 'arus/doctrine-bridge:^1.10'
composer require 'arus/doctrine-bridge:^1.18'
```

## Examples of using
Expand Down Expand Up @@ -177,11 +177,11 @@ use Arus\Doctrine\Bridge\Validator\Constraint\UniqueEntity;

/**
* @UniqueEntity({"foo"})
*
*
* @UniqueEntity({"bar", "baz"})
*
*
* @UniqueEntity({"qux"}, atPath="customPropertyPath")
*
*
* @UniqueEntity({"quux"}, message="The value {{ value }} already exists!")
*/
class Entry
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"php-di/php-di": "^6.0",
"doctrine/orm": "^2.7",
"doctrine/migrations": "^2.2",
"symfony/validator": "^5.0"
"symfony/validator": "^5.0",
"monolog/monolog": "^2.0"
},
"autoload": {
"psr-4": {
Expand Down
54 changes: 54 additions & 0 deletions src/SQLLogger.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php declare(strict_types=1);

namespace Arus\Doctrine\Bridge;

/**
* Import classes
*/
use Doctrine\DBAL\Logging\DebugStack;
use Psr\Log\LoggerInterface;

/**
* Import functions
*/
use function array_pop;
use function sprintf;

/**
* SQLLogger
*/
final class SQLLogger extends DebugStack
{

/**
* @var LoggerInterface
*/
private $logger;

/**
* @param LoggerInterface $logger
*/
public function __construct(LoggerInterface $logger)
{
$this->logger = $logger;
}

/**
* {@inheritDoc}
*/
public function stopQuery()
{
parent::stopQuery();

$report = array_pop($this->queries);

$this->logger->debug(sprintf(
'[%2.3fµ] %s',
$report['executionMS'] * 1000,
$report['sql']
), [
'params' => $report['params'],
'types' => $report['types'],
]);
}
}
5 changes: 5 additions & 0 deletions tests/Fixture/ContainerAwareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@
* Import classes
*/
use Arus\Doctrine\Bridge\ManagerRegistry;
use Arus\Doctrine\Bridge\SQLLogger;
use DI\Container;
use DI\ContainerBuilder;
use Monolog\Logger;
use Symfony\Component\Validator\ContainerConstraintValidatorFactory;
use Symfony\Component\Validator\Validation;

/**
* Import functions
*/
use function DI\autowire;
use function DI\create;
use function DI\get;
use function DI\factory;

/**
Expand Down Expand Up @@ -54,6 +58,7 @@ private function getContainer() : Container
'types' => [
Example1DbalType::NAME => Example1DbalType::class,
],
'sql_logger' => new SQLLogger(new Logger('test')),
],
'bar' => [
'connection' => [
Expand Down

0 comments on commit d2d892b

Please sign in to comment.