Skip to content

Commit

Permalink
Use Nette 2.4 as minimal version
Browse files Browse the repository at this point in the history
  • Loading branch information
fmasa committed Mar 27, 2018
1 parent 7bdbc5e commit af1c3e7
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 192 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ language: php
sudo: false

env:
- NETTE=2.1
- NETTE=2.2
- NETTE=2.3
- NETTE=2.4
- NETTE=master

Expand Down
28 changes: 5 additions & 23 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,14 @@
"require": {
"php": ">=5.6",
"skautis/skautis": "~2.0@dev",
"nette/di": "~2.1@dev",
"nette/http": "~2.1@dev",
"nette/utils": "^2.4"
"nette/di": "^2.4@dev",
"nette/http": "^2.4@dev",
"nette/utils": "^2.4@dev"
},
"require-dev": {
"nette/tester": "~1.3",
"nette/nette": "~2.1@dev",
"nette/application": "~2.1@dev",
"nette/bootstrap": "~2.1@dev",
"nette/caching": "~2.1@dev",
"nette/component-model": "~2.1@dev",
"nette/database": "~2.1@dev",
"nette/deprecated": "~2.1@dev",
"nette/finder": "~2.1@dev",
"nette/forms": "~2.1@dev",
"nette/mail": "~2.1@dev",
"nette/neon": "~2.1@dev",
"nette/php-generator": "~2.1@dev",
"nette/reflection": "~2.1@dev",
"nette/robot-loader": "~2.1@dev",
"nette/safe-stream": "~2.1@dev",
"nette/security": "~2.1@dev",
"nette/tokenizer": "~2.1@dev",
"nette/utils": "~2.1@dev",
"latte/latte": "~2.1@dev",
"tracy/tracy": "~2.1@dev"
"nette/nette": "^2.4@dev",
"nette/utils": "^2.4@dev"
},
"suggest": {
"tracy/tracy": "to enable skautis panel for Tracy debug bar.",
Expand Down
41 changes: 14 additions & 27 deletions src/SkautisExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use Nette;
use Nette\DI\Config;
use Skautis;
use Tracy\Debugger;


/**
Expand All @@ -16,13 +18,13 @@ class SkautisExtension extends Nette\DI\CompilerExtension
{

/** @var array */
public $defaults = array(
public $defaults = [
'applicationId' => NULL,
'testMode' => FALSE,
'profiler' => NULL,
'cache' => TRUE,
'compression' => TRUE,
);
];


public function loadConfiguration()
Expand All @@ -32,46 +34,31 @@ public function loadConfiguration()
$config['profiler'] = isset($config['profiler']) ? $config['profiler'] : !empty($container->parameters['debugMode']);

$container->addDefinition($this->prefix('config'))
->setClass('Skautis\Config', array($config['applicationId'], $config['testMode'], $config['cache'], $config['compression']));
->setClass(Skautis\Config::class, array($config['applicationId'], $config['testMode'], $config['cache'], $config['compression']));

$container->addDefinition($this->prefix('webServiceFactory'))
->setClass('Skautis\Wsdl\WebServiceFactory');
->setClass(Skautis\Wsdl\WebServiceFactory::class);

$manager = $container->addDefinition($this->prefix('wsdlManager'))
->setClass('Skautis\Wsdl\WsdlManager');
->setClass(Skautis\Wsdl\WsdlManager::class);

$container->addDefinition($this->prefix('session'))
->setClass('Skautis\Nette\SessionAdapter');
->setClass(SessionAdapter::class);

$container->addDefinition($this->prefix('user'))
->setClass('Skautis\User');
->setClass(Skautis\User::class);

$container->addDefinition($this->prefix('skautis'))
->setClass('Skautis\Skautis');
->setClass(Skautis\Skautis::class);

if ($config['profiler'] && (class_exists('Tracy\Debugger') || class_exists('Nette\Diagnostics\Debugger'))) {
if ($config['profiler'] && class_exists(Debugger::class)) {
$panel = $container->addDefinition($this->prefix('panel'))
->setClass('Skautis\Nette\Tracy\Panel');
$manager->addSetup(array($panel, 'register'), array($manager));
->setClass(Skautis\Nette\Tracy\Panel::class);
$manager->addSetup([$panel, 'register'], array($manager));
}
}


/**
* BC with nette/di <2.3
* @param string $name
* @param array $args
* @return mixed
*/
public function __call($name, $args)
{
if ($name === 'validateConfig') {
return call_user_func_array(array($this, '_validateConfig'), $args);
}
return parent::__call($name, $args);
}


/**
* Checks whether $config contains only $expected items and returns combined array.
* BC with nette/di <2.3
Expand All @@ -81,7 +68,7 @@ public function __call($name, $args)
* @return array
* @throws Nette\InvalidStateException
*/
private function _validateConfig(array $expected, array $config = NULL, $name = NULL)
private function validateConfig(array $expected, array $config = NULL, $name = NULL)
{
if (func_num_args() === 1) {
$config = $this->config;
Expand Down
28 changes: 3 additions & 25 deletions src/Tracy/Panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@
use Skautis\Wsdl\WsdlManager;
use Tracy;


if (!interface_exists('Tracy\IBarPanel') && interface_exists('Nette\Diagnostics\IBarPanel')) {
// BC with Nette 2.1
class_alias('Nette\Diagnostics\IBarPanel', 'Tracy\IBarPanel');
}


/**
* Skautis panel for Tracy.
*
Expand All @@ -25,27 +18,12 @@ class Panel implements Tracy\IBarPanel
use Nette\SmartObject;

/** @var string */
private $htmlPrefix;

/** @var string */
private $debuggerClass;
private $htmlPrefix = 'tracy';

/** @var array */
private $queries = array();


public function __construct()
{
if (!class_exists('Tracy\Debugger') && class_exists('Nette\Diagnostics\Debugger')) {
$this->htmlPrefix = 'nette';
$this->debuggerClass = 'Nette\Diagnostics\Debugger';
} else {
$this->htmlPrefix = 'tracy';
$this->debuggerClass = 'Tracy\Debugger';
}
}


/**
* Registers event listener on WebService objects via WsdlManager
*
Expand All @@ -55,7 +33,7 @@ public function register(WsdlManager $wsdlManager)
{
$wsdlManager->addWebServiceListener(WebService::EVENT_SUCCESS, array($this, 'logEvent'));
$wsdlManager->addWebServiceListener(WebService::EVENT_FAILURE, array($this, 'logEvent'));
call_user_func(array($this->debuggerClass, 'getBar'))->addPanel($this);
call_user_func([Tracy\Debugger::class, 'getBar'])->addPanel($this);
}


Expand Down Expand Up @@ -137,7 +115,7 @@ protected function prepareTrace(array $trace)
*/
protected function dump($object)
{
return call_user_func(array($this->debuggerClass, 'dump'), $object, TRUE);
return call_user_func([Tracy\Debugger::class, 'dump'], $object, TRUE);
}


Expand Down
6 changes: 4 additions & 2 deletions tests/SkautisNette/SkautisExtension.debug.phpt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

use Tester\Assert;
use Skautis\Skautis;
use Skautis\Nette\Tracy\Panel;


require __DIR__ . '/../bootstrap.php';
Expand All @@ -13,6 +15,6 @@ $configurator->addConfig(__DIR__ . '/files/config.neon');
$container = $configurator->createContainer();

Assert::false($container->isCreated('skautis.panel'));
Assert::type('Skautis\Skautis', $container->getService('skautis.skautis'));
Assert::type(Skautis::class, $container->getService('skautis.skautis'));
Assert::true($container->isCreated('skautis.panel'));
Assert::type('Skautis\Nette\Tracy\Panel', $container->getService('skautis.panel'));
Assert::type(Panel::class, $container->getService('skautis.panel'));
4 changes: 2 additions & 2 deletions tests/SkautisNette/SkautisExtension.production.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use Tester\Assert;

use Skautis\Skautis;

require __DIR__ . '/../bootstrap.php';

Expand All @@ -12,5 +12,5 @@ $configurator->setDebugMode(FALSE);
$configurator->addConfig(__DIR__ . '/files/config.neon');
$container = $configurator->createContainer();

Assert::type('Skautis\Skautis', $container->getService('skautis.skautis'));
Assert::type(Skautis::class, $container->getService('skautis.skautis'));
Assert::false($container->hasService('skautis.panel'));
34 changes: 0 additions & 34 deletions tests/composer-nette-2.1.json

This file was deleted.

38 changes: 0 additions & 38 deletions tests/composer-nette-2.2.json

This file was deleted.

38 changes: 0 additions & 38 deletions tests/composer-nette-2.3.json

This file was deleted.

0 comments on commit af1c3e7

Please sign in to comment.