Skip to content
Permalink
Browse files

Nette 3

  • Loading branch information...
mabar authored and f3l1x committed Jun 13, 2019
1 parent 06a83cd commit db0e4f9e2335023a1278b8d0b4201b92b76c44fa
Showing with 28 additions and 28 deletions.
  1. +6 −5 README.md
  2. +2 −7 composer.json
  3. +20 −16 src/DI/DebugPlugin.php
@@ -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

@@ -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",
@@ -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"
@@ -48,7 +43,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "0.6.x-dev"
"dev-master": "0.7.x-dev"
}
}
}
@@ -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;
@@ -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),
]);
}
/**
@@ -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);
@@ -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]);
}
}

0 comments on commit db0e4f9

Please sign in to comment.
You can’t perform that action at this time.