Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
language: php

php:
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4

env:
- SYMFONY_VERSION=2.8.*
- SYMFONY_VERSION=3.3.*
- SYMFONY_VERSION=4.4.*

before_script:
- composer require symfony/framework-bundle:${SYMFONY_VERSION} --no-update
- composer update --prefer-source

script: phpunit
script:
- make analysis
- make unit
30 changes: 18 additions & 12 deletions Controller/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Lexik\Bundle\MonologBrowserBundle\Controller;

use Lexik\Bundle\MonologBrowserBundle\Model\LogRepository;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;

Expand All @@ -14,18 +15,31 @@
*/
class DefaultController extends Controller
{
/**
* @var LogRepository
*/
private $logRepository;

/**
* DefaultController constructor.
*/
public function __construct(LogRepository $logRepository)
{
$this->logRepository = $logRepository;
}

/**
* @param Request $request
* @return \Symfony\Component\HttpFoundation\Response
*/
public function indexAction(Request $request)
{
try {
$query = $this->getLogRepository()->getLogsQueryBuilder();
$query = $this->logRepository->getLogsQueryBuilder();

$filter = $this->get('form.factory')->create(LogSearchType::class, null, array(
'query_builder' => $query,
'log_levels' => $this->getLogRepository()->getLogsLevel(),
'log_levels' => $this->logRepository->getLogsLevel(),
));

$filter->submit($request->get($filter->getName()));
Expand Down Expand Up @@ -55,13 +69,13 @@ public function indexAction(Request $request)
*/
public function showAction(Request $request, $id)
{
$log = $this->getLogRepository()->getLogById($id);
$log = $this->logRepository->getLogById($id);

if (null === $log) {
throw $this->createNotFoundException('The log entry does not exist');
}

$similarLogsQuery = $this->getLogRepository()->getSimilarLogsQueryBuilder($log);
$similarLogsQuery = $this->logRepository->getSimilarLogsQueryBuilder($log);

$similarLogs = $this->get('knp_paginator')->paginate(
$similarLogsQuery,
Expand All @@ -83,12 +97,4 @@ protected function getBaseLayout()
{
return $this->container->getParameter('lexik_monolog_browser.base_layout');
}

/**
* @return \Lexik\Bundle\MonologBrowserBundle\Model\LogRepository
*/
protected function getLogRepository()
{
return $this->get('lexik_monolog_browser.model.log_repository');
}
}
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function getConfigTreeBuilder()
->scalarNode('table_name')->defaultValue('monolog_entries')->end()
->scalarNode('connection_name')->end()
->arrayNode('connection')
->cannotBeEmpty()
//->cannotBeEmpty()
->children()
->scalarNode('driver')->end()
->scalarNode('driverClass')->end()
Expand Down
2 changes: 1 addition & 1 deletion Handler/DoctrineDBALHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class DoctrineDBALHandler extends AbstractProcessingHandler
* @param Connection $connection
* @param string $tableName
* @param int $level
* @param string $bubble
* @param bool $bubble
*/
public function __construct(Connection $connection, $tableName, $level = Logger::DEBUG, $bubble = true)
{
Expand Down
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.PHONY: all
default: all;

analysis:
vendor/bin/phpstan.phar analyse -c phpstan.neon -l 2 .

unit:
vendor/bin/phpunit --no-coverage

all: analysis unit
2 changes: 1 addition & 1 deletion Model/LogRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Lexik\Bundle\MonologBrowserBundle\Model;

use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Connection;

use Lexik\Bundle\MonologBrowserBundle\Model\Log;

Expand Down
2 changes: 1 addition & 1 deletion Model/SchemaBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Lexik\Bundle\MonologBrowserBundle\Model;

use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\SchemaDiff;
use Doctrine\DBAL\Schema\Comparator;
Expand Down
6 changes: 6 additions & 0 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
</parameters>

<services>
<defaults autowire="true" autoconfigure="true"/>

<service id="lexik_monolog_browser.handler.doctrine_dbal" class="%lexik_monolog_browser.handler.doctrine_dbal.class%">
<argument type="service" id="lexik_monolog_browser.doctrine_dbal.connection" />
<argument>%lexik_monolog_browser.doctrine.table_name%</argument>
Expand All @@ -19,5 +21,9 @@
<argument type="service" id="lexik_monolog_browser.doctrine_dbal.connection" />
<argument>%lexik_monolog_browser.doctrine.table_name%</argument>
</service>

<service id="Lexik\Bundle\MonologBrowserBundle\Controller\DefaultController">
<argument key="$logRepository" type="service" id="lexik_monolog_browser.model.log_repository"/>
</service>
</services>
</container>
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Lexik\Bundle\MonologBrowserBundle\Tests\DependencyInjection;

use Symfony\Component\Yaml\Parser;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;

use Lexik\Bundle\MonologBrowserBundle\DependencyInjection\LexikMonologBrowserExtension;

class LexikMonologBrowserExtensionTest extends \PHPUnit_Framework_TestCase
class LexikMonologBrowserExtensionTest extends TestCase
{
public function testConfigLoad()
{
Expand Down
12 changes: 7 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@
}
],
"require": {
"php": ">=5.6",
"symfony/framework-bundle": "^2.8|^3",
"php": ">=7.1",
"symfony/framework-bundle": "^4",
"knplabs/knp-paginator-bundle": ">=2.3"
},
"require-dev": {
"monolog/monolog": "^1.24",
"doctrine/dbal": "*",
"symfony/console": "^2.8|^3",
"symfony/form": "^2.8|^3",
"symfony/options-resolver": "^2.8|^3"
"symfony/console": "^4",
"symfony/form": "^4",
"phpunit/phpunit": "^7",
"symfony/options-resolver": "^4",
"phpstan/phpstan-shim": "^0.11"
},
"autoload": {
"psr-0": { "Lexik\\Bundle\\MonologBrowserBundle": "" }
Expand Down
5 changes: 5 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
parameters:
excludes_analyse:
- %currentWorkingDirectory%/Tests/*
- %currentWorkingDirectory%/DependencyInjection/Configuration.php
- %currentWorkingDirectory%/vendor/*