Skip to content

Commit

Permalink
Nette 3
Browse files Browse the repository at this point in the history
  • Loading branch information
mabar authored and Milan Felix 艩ulc committed Jul 7, 2019
1 parent 06a83cd commit db0e4f9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
11 changes: 6 additions & 5 deletions README.md
Expand Up @@ -22,11 +22,12 @@ Debug tools for [Apitte](https://github.com/apitte/core), based on [Tracy debugg

## Version

| State | Version | Branch | PHP | Composer |
|-------------|--------------|----------|----------|-------------------------------------------------|
| development | `^0.6.0` | `master` | `>= 7.1` | `minimum-stability: dev`, `prefer-stable: true` |
| stable | `^0.5.0` | `master` | `>= 7.1` | |
| stable | `^0.3.0` | `master` | `>= 5.6` | |
| State | Version | Branch | Nette | PHP |
|-------------|---------|----------|-------|---------|
| dev | `^0.7` | `master` | 3.0+ | `^7.2` |
| stable | `^0.6` | `master` | 3.0+ | `^7.2` |
| stable | `^0.5` | `master` | 2.4 | `>=7.1` |
| stable | `^0.3` | `master` | 2.4 | `>=5.6` |

## Maintainers

Expand Down
9 changes: 2 additions & 7 deletions composer.json
Expand Up @@ -19,11 +19,10 @@
"require": {
"php": "^7.2",
"apitte/core": "^0.6.0",
"tracy/tracy": "~2.4.14 || ~2.5.0 || ~2.6.0"
"tracy/tracy": "~2.6.0"
},
"require-dev": {
"apitte/negotiation": "^0.6.0",
"nette/di": "~2.4.12",
"ninjify/nunjuck": "^0.2.0",
"ninjify/qa": "^0.8.0",
"phpstan/extension-installer": "^1.0",
Expand All @@ -32,10 +31,6 @@
"phpstan/phpstan-shim": "^0.11",
"phpstan/phpstan-strict-rules": "^0.11"
},
"conflict": {
"apitte/negotiation": "<0.6.0",
"nette/di": "<2.4.12"
},
"autoload": {
"psr-4": {
"Apitte\\Debug\\": "src"
Expand All @@ -48,7 +43,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "0.6.x-dev"
"dev-master": "0.7.x-dev"
}
}
}
36 changes: 20 additions & 16 deletions src/DI/DebugPlugin.php
Expand Up @@ -3,9 +3,8 @@
namespace Apitte\Debug\DI;

use Apitte\Core\DI\ApiExtension;
use Apitte\Core\DI\Plugin\AbstractPlugin;
use Apitte\Core\DI\Plugin\CoreSchemaPlugin;
use Apitte\Core\DI\Plugin\PluginCompiler;
use Apitte\Core\DI\Plugin\Plugin;
use Apitte\Debug\Negotiation\Transformer\DebugDataTransformer;
use Apitte\Debug\Negotiation\Transformer\DebugTransformer;
use Apitte\Debug\Schema\Serialization\DebugSchemaDecorator;
Expand All @@ -15,22 +14,27 @@
use Apitte\Negotiation\DI\NegotiationPlugin;
use Nette\DI\ContainerBuilder;
use Nette\PhpGenerator\ClassType;
use Nette\Schema\Expect;
use Nette\Schema\Schema;
use stdClass;
use Tracy\Debugger;

class DebugPlugin extends AbstractPlugin
/**
* @property-read stdClass $config
*/
class DebugPlugin extends Plugin
{

public const PLUGIN_NAME = 'debug';

/** @var mixed[] */
protected $defaults = [
'debug' => true,
];
public static function getName(): string
{
return 'debug';
}

public function __construct(PluginCompiler $compiler)
protected function getConfigSchema(): Schema
{
parent::__construct($compiler);
$this->name = self::PLUGIN_NAME;
return Expect::structure([
'debug' => Expect::bool(true),
]);
}

/**
Expand All @@ -40,9 +44,9 @@ public function loadPluginConfiguration(): void
{
$builder = $this->getContainerBuilder();
$global = $this->compiler->getExtension()->getConfig();
$config = $this->getConfig();
$config = $this->config;

if ($global['debug'] !== true && $config['debug'] !== true) return;
if (!$global->debug || !$config->debug) return;

$builder->addDefinition($this->prefix('panel'))
->setFactory(ApiPanel::class);
Expand Down Expand Up @@ -76,14 +80,14 @@ protected function loadNegotiationDebugConfiguration(): void
public function afterPluginCompile(ClassType $class): void
{
$global = $this->compiler->getExtension()->getConfig();
$config = $this->getConfig();
$config = $this->config;

$initialize = $class->getMethod('initialize');

$initialize->addBody('?::register($this->getService(?));', [ContainerBuilder::literal(ApiBlueScreen::class), 'tracy.blueScreen']);
$initialize->addBody('?::register($this->getService(?));', [ContainerBuilder::literal(ValidationBlueScreen::class), 'tracy.blueScreen']);

if ($global['debug'] === true && $config['debug'] === true) {
if ($global->debug && $config->debug) {
$initialize->addBody('$this->getService(?)->addPanel($this->getByType(?));', ['tracy.bar', ApiPanel::class]);
}
}
Expand Down

0 comments on commit db0e4f9

Please sign in to comment.