Skip to content

Commit

Permalink
Merge pull request #30 from ARCANEDEV/patch-1
Browse files Browse the repository at this point in the history
Updating LogMenu Utility
  • Loading branch information
arcanedev-maroc committed Dec 11, 2015
2 parents 315c732 + 5817ef8 commit e9c4355
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 13 deletions.
2 changes: 2 additions & 0 deletions config/log-viewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
| ------------------------------------------------------------------------------------------------
*/
'menu' => [
'filter-route' => 'log-viewer::logs.filter',

'icons-enabled' => true,
],

Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/FactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
interface FactoryInterface
{
/* ------------------------------------------------------------------------------------------------
| Getter & Setters
| Getters & Setters
| ------------------------------------------------------------------------------------------------
*/
/**
Expand Down
14 changes: 12 additions & 2 deletions src/Contracts/LogMenuInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php namespace Arcanedev\LogViewer\Contracts;

use Arcanedev\LogViewer\Entities\Log;
use Illuminate\Contracts\Config\Repository;

/**
* Interface LogMenuInterface
Expand All @@ -14,6 +15,15 @@ interface LogMenuInterface
| Getters & Setters
| ------------------------------------------------------------------------------------------------
*/
/**
* Set the config instance.
*
* @param \Illuminate\Contracts\Config\Repository $config
*
* @return self
*/
public function setConfig(Repository $config);

/**
* Set the log styler instance.
*
Expand All @@ -30,8 +40,8 @@ public function setLogStyler(LogStylerInterface $styler);
/**
* Make log menu.
*
* @param Log $log
* @param bool $trans
* @param \Arcanedev\LogViewer\Entities\Log $log
* @param bool $trans
*
* @return array
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Utilities/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function setFilesystem(FilesystemInterface $filesystem)
/**
* Get the log levels instance.
*
* @return \Arcanedev\LogViewer\Contracts\LogLevelsInterface $levels
* @return \Arcanedev\LogViewer\Contracts\LogLevelsInterface
*/
public function getLevels()
{
Expand All @@ -89,7 +89,7 @@ public function getLevels()
/**
* Set the log levels instance.
*
* @param \Arcanedev\LogViewer\Contracts\LogLevelsInterface $levels
* @param \Arcanedev\LogViewer\Contracts\LogLevelsInterface $levels
*
* @return self
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Utilities/LogChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function messages()
}

/**
* Check if the check passes.
* Check if the checker passes.
*
* @return bool
*/
Expand All @@ -167,7 +167,7 @@ public function passes()
}

/**
* Check if the check fails.
* Check if the checker fails.
*
* @return bool
*/
Expand Down
27 changes: 21 additions & 6 deletions src/Utilities/LogMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use Arcanedev\LogViewer\Contracts\LogMenuInterface;
use Arcanedev\LogViewer\Contracts\LogStylerInterface;
use Arcanedev\LogViewer\Entities\Log;
use Illuminate\Contracts\Config\Repository as Config;
use Illuminate\Contracts\Config\Repository;

/**
* Class LogMenu
Expand Down Expand Up @@ -38,19 +38,33 @@ class LogMenu implements LogMenuInterface
/**
* Create the LogMenu instance.
*
* @param Config $config
* @param LogStylerInterface $styler
* @param \Illuminate\Contracts\Config\Repository $config
* @param \Arcanedev\LogViewer\Contracts\LogStylerInterface $styler
*/
public function __construct(Config $config, LogStylerInterface $styler)
public function __construct(Repository $config, LogStylerInterface $styler)
{
$this->config = $config;
$this->setConfig($config);
$this->setLogStyler($styler);
}

/* ------------------------------------------------------------------------------------------------
| Getters & Setters
| ------------------------------------------------------------------------------------------------
*/
/**
* Set the config instance.
*
* @param \Illuminate\Contracts\Config\Repository $config
*
* @return self
*/
public function setConfig(Repository $config)
{
$this->config = $config;

return $this;
}

/**
* Set the log styler instance.
*
Expand Down Expand Up @@ -80,10 +94,11 @@ public function setLogStyler(LogStylerInterface $styler)
public function make(Log $log, $trans = true)
{
$items = [];
$route = $this->config('menu.filter-route');

foreach($log->tree($trans) as $level => $item) {
$items[$level] = array_merge($item, [
'url' => route('log-viewer::logs.filter', [$log->date, $level]),
'url' => route($route, [$log->date, $level]),
'icon' => $this->isIconsEnabled() ? $this->styler->icon($level) : '',
]);
}
Expand Down

0 comments on commit e9c4355

Please sign in to comment.