Skip to content
Permalink
Browse files

Nette 3

  • Loading branch information...
mabar authored and f3l1x committed Jun 13, 2019
1 parent 8af9c79 commit 304c352e69d74ad0091d0f774127d566a9ba421b
Showing with 32 additions and 31 deletions.
  1. +6 −5 README.md
  2. +3 −7 composer.json
  3. +23 −19 src/DI/MiddlewaresPlugin.php
@@ -22,11 +22,12 @@ Middlewares for [Apitte](https://github.com/apitte/core).

## 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

@@ -17,13 +17,12 @@
}
],
"require": {
"php": ">= 7.1",
"php": "^7.2",
"apitte/core": "^0.6.0",
"contributte/middlewares": "^0.6.0|^0.7.0|^0.8.0"
"contributte/middlewares": "^0.9.0"
},
"require-dev": {
"mockery/mockery": "^0.9.9",
"nette/di": "~2.4.15",
"ninjify/nunjuck": "^0.2.0",
"ninjify/qa": "^0.8.0",
"phpstan/extension-installer": "^1.0",
@@ -32,9 +31,6 @@
"phpstan/phpstan-shim": "^0.11",
"phpstan/phpstan-strict-rules": "^0.11"
},
"conflict": {
"nette/di": "<2.4.15"
},
"autoload": {
"psr-4": {
"Apitte\\Middlewares\\": "src"
@@ -47,7 +43,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "0.6.x-dev"
"dev-master": "0.7.x-dev"
}
}
}
@@ -2,28 +2,32 @@
namespace Apitte\Middlewares\DI;
use Apitte\Core\DI\Plugin\AbstractPlugin;
use Apitte\Core\DI\Plugin\PluginCompiler;
use Apitte\Core\DI\Plugin\Plugin;
use Apitte\Middlewares\ApiMiddleware;
use Contributte\Middlewares\AutoBasePathMiddleware;
use Contributte\Middlewares\DI\MiddlewaresExtension;
use Contributte\Middlewares\TracyMiddleware;
class MiddlewaresPlugin extends AbstractPlugin
use Nette\Schema\Expect;
use Nette\Schema\Schema;
use stdClass;
/**
* @property-read stdClass $config
*/
class MiddlewaresPlugin extends Plugin
{
public const PLUGIN_NAME = 'middlewares';
/** @var mixed[] */
protected $defaults = [
'tracy' => true,
'autobasepath' => true,
];
public static function getName(): string
{
return 'middlewares';
}
public function __construct(PluginCompiler $compiler)
protected function getConfigSchema(): Schema
{
parent::__construct($compiler);
$this->name = self::PLUGIN_NAME;
return Expect::structure([
'tracy' => Expect::bool(true),
'autobasepath' => Expect::bool(true),
]);
}
/**
@@ -32,16 +36,16 @@ public function __construct(PluginCompiler $compiler)
public function loadPluginConfiguration(): void
{
$builder = $this->getContainerBuilder();
$global = $this->compiler->getExtension()->getConfig();
$config = $this->getConfig();
$globalConfig = $this->compiler->getExtension()->getConfig();
$config = $this->config;
if ($config['tracy'] === true) {
if ($config->tracy) {
$builder->addDefinition($this->prefix('tracy'))
->setFactory(TracyMiddleware::class . '::factory', [$global['debug']])
->setFactory(TracyMiddleware::class . '::factory', [$globalConfig->debug])
->addTag(MiddlewaresExtension::MIDDLEWARE_TAG, ['priority' => 100]);
}
if ($config['autobasepath'] === true) {
if ($config->autobasepath) {
$builder->addDefinition($this->prefix('autobasepath'))
->setFactory(AutoBasePathMiddleware::class)
->addTag(MiddlewaresExtension::MIDDLEWARE_TAG, ['priority' => 200]);

0 comments on commit 304c352

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