Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update skautis/skautis to 3.0.0-alpha.4 #33

Merged
merged 13 commits into from
Sep 20, 2022
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"require": {
"php": ">=7.1",
"skautis/skautis": "3.0.0-alpha.1",
"skautis/skautis": "3.0.0-alpha.4",
"nette/di": "^3.0",
"nette/http": "^3.0",
"nette/utils": "^3.0"
Expand Down
2 changes: 1 addition & 1 deletion src/SessionAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Skautis\Nette;

use Nette;
use Skautis\SessionAdapter\AdapterInterface;
use Skaut\Skautis\SessionAdapter\AdapterInterface;


class SessionAdapter implements AdapterInterface
Expand Down
11 changes: 5 additions & 6 deletions src/SkautisExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@

use Nette;
use Nette\Schema\Expect;
use Skautis\Config;
use Skautis\Wsdl\WebServiceFactory;
use Skautis\Wsdl\WsdlManager;
use Skautis\Nette\SessionAdapter;
use Skautis\User;
use Skautis\Skautis;
use Skaut\Skautis\Config;
use Skaut\Skautis\Wsdl\WebServiceFactory;
use Skaut\Skautis\Wsdl\WsdlManager;
use Skaut\Skautis\User;
use Skaut\Skautis\Skautis;
use Skautis\Nette\Tracy\Panel;
use Tracy\Debugger;

Expand Down
44 changes: 44 additions & 0 deletions src/Tracy/EventDispatcher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);

namespace Skautis\Nette\Tracy;

use Psr\EventDispatcher\EventDispatcherInterface;
use Skaut\Skautis\Wsdl\Event\RequestFailEvent;
use Skaut\Skautis\Wsdl\Event\RequestPostEvent;
use Skaut\Skautis\Wsdl\Event\RequestPreEvent;
use stdClass;


/**
* Trida pro logovani dotazu.
*/
class EventDispatcher implements EventDispatcherInterface
{
/** @var SkautisQuery[] */
private $queries = [];

/**
* @param RequestPreEvent|RequestPostEvent|RequestFailEvent $event
*/
public function dispatch($event): void
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tady mě IDE nutí zvednou PHP na 7.2, zvednul jsem i v composeru, skautis/skautis chce stejně >= 7.3

Declaration must be compatible with EventDispatcherInterface->dispatch(event: object|\Psr\EventDispatcher\object). This is only allowed starting with PHP 7.2. 

{
switch (true) {
case $event instanceof RequestPreEvent:
// no-op
break;
case $event instanceof RequestPostEvent:
$this->queries[] = SkautisQuery::createFromPostEvent($event);
break;
case $event instanceof RequestFailEvent:
$this->queries[] = SkautisQuery::createFromFailEvent($event);
break;
}
}

/** @return SkautisQuery[] */
public function getQueries(): array
{
return $this->queries;
}
}
35 changes: 15 additions & 20 deletions src/Tracy/Panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
namespace Skautis\Nette\Tracy;

use Nette;
use Skautis\SkautisQuery;
use Skautis\Wsdl\WebService;
use Skautis\Wsdl\WsdlManager;
use Skaut\Skautis\Wsdl\WsdlManager;
use Tracy;
use Tracy\Debugger;

Expand All @@ -19,41 +17,38 @@
*/
class Panel implements Tracy\IBarPanel
{

use Nette\SmartObject;

/** @var SkautisQuery[] */
private $queries = [];
private $eventDispatcher;

/**
* @param $eventDispatcher
*/
public function __construct()
{
$this->eventDispatcher = new EventDispatcher();
}

/**
/**
* Registers event listener on WebService objects via WsdlManager
*/
public function register(WsdlManager $wsdlManager): void
{
$wsdlManager->addWebServiceListener(WebService::EVENT_SUCCESS, [$this, 'logEvent']);
$wsdlManager->addWebServiceListener(WebService::EVENT_FAILURE, [$this, 'logEvent']);
$wsdlManager->setEventDispatcher($this->eventDispatcher);
Debugger::getBar()->addPanel($this);
}


public function logEvent(SkautisQuery $query): void
{
$this->queries[] = $query;
}


/**
* @inheritdoc
*/
public function getTab(): string
{
$totalTime = 0;
foreach ($this->queries as $query) {
foreach ($this->eventDispatcher->getQueries() as $query) {
$totalTime += $query->time;
}
return '<span title="skautis"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAKQWlDQ1BJQ0MgUHJvZmlsZQAASA2dlndUU9kWh8+9N73QEiIgJfQaegkg0jtIFQRRiUmAUAKGhCZ2RAVGFBEpVmRUwAFHhyJjRRQLg4Ji1wnyEFDGwVFEReXdjGsJ7601896a/cdZ39nnt9fZZ+9917oAUPyCBMJ0WAGANKFYFO7rwVwSE8vE9wIYEAEOWAHA4WZmBEf4RALU/L09mZmoSMaz9u4ugGS72yy/UCZz1v9/kSI3QyQGAApF1TY8fiYX5QKUU7PFGTL/BMr0lSkyhjEyFqEJoqwi48SvbPan5iu7yZiXJuShGlnOGbw0noy7UN6aJeGjjAShXJgl4GejfAdlvVRJmgDl9yjT0/icTAAwFJlfzOcmoWyJMkUUGe6J8gIACJTEObxyDov5OWieAHimZ+SKBIlJYqYR15hp5ejIZvrxs1P5YjErlMNN4Yh4TM/0tAyOMBeAr2+WRQElWW2ZaJHtrRzt7VnW5mj5v9nfHn5T/T3IevtV8Sbsz55BjJ5Z32zsrC+9FgD2JFqbHbO+lVUAtG0GQOXhrE/vIADyBQC03pzzHoZsXpLE4gwnC4vs7GxzAZ9rLivoN/ufgm/Kv4Y595nL7vtWO6YXP4EjSRUzZUXlpqemS0TMzAwOl89k/fcQ/+PAOWnNycMsnJ/AF/GF6FVR6JQJhIlou4U8gViQLmQKhH/V4X8YNicHGX6daxRodV8AfYU5ULhJB8hvPQBDIwMkbj96An3rWxAxCsi+vGitka9zjzJ6/uf6Hwtcim7hTEEiU+b2DI9kciWiLBmj34RswQISkAd0oAo0gS4wAixgDRyAM3AD3iAAhIBIEAOWAy5IAmlABLJBPtgACkEx2AF2g2pwANSBetAEToI2cAZcBFfADXALDIBHQAqGwUswAd6BaQiC8BAVokGqkBakD5l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VEgZwEq/qg01PfVuSYcSZiDcWHeQyHouLDkTIWTjsK3g2FwPz5jEMLURgyKGFVPRyYcBJDenQBrYnHo+lYNLJIVHq6hDcNkvScQPy8jOg53hLoszdObyuR+f3ZOh5x4yRc3eFAOFJfNTYqBtyRucXmVbPZ8Suy4ngy4W+UMn7dkDZ320RaeTHgVkN3zut6zBKFnsr6uosBwChJBQzb2vL1FGe1o11G3QqGkFRhNMFKFUaTCzTZbkltx7uCX8tYQd/iiL15H5DOkvbMwuy+HYvT+H1MFsqCJGjl6tvmHdN737mf8b4y+stA0+rW/8l3xukowQtPbrKo85+138CPAUnGWDNKlEAAAAASUVORK5CYII=">'
. count($this->queries) . ' queries'
. count($this->eventDispatcher->getQueries()) . ' queries'
. ($totalTime ? sprintf(' / %0.1f&nbsp;ms', $totalTime * 1000) : '')
. '</span>';
}
Expand All @@ -66,7 +61,7 @@ public function getPanel(): string
{
$cnt = 0;
$s = "";
foreach ($this->queries as $query) {
foreach ($this->eventDispatcher->getQueries() as $query) {
$rowId = "tracy-debug-Skautis-args-row-$cnt";
$s .= "<tr>"
. "<td>" . sprintf('%0.2f', $query->time * 1000) . "</td>"
Expand All @@ -77,7 +72,7 @@ public function getPanel(): string
$cnt++;
}

return empty($this->queries) ? '' :
return empty($this->eventDispatcher->getQueries()) ? '' :
'<h1>Skautis</h1>'
. '<div class="tracy-inner">'
. '<table>'
Expand Down
62 changes: 62 additions & 0 deletions src/Tracy/SkautisQuery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
declare(strict_types=1);

namespace Skautis\Nette\Tracy;

use Skaut\Skautis\Wsdl\Event\RequestFailEvent;
use Skaut\Skautis\Wsdl\Event\RequestPostEvent;
use Skaut\Skautis\Wsdl\Event\RequestPreEvent;


/**
* Objekt s informacemi o dotazu.
*/
class SkautisQuery
{
/**
* Nazev funkce volane pomoci SOAP requestu.
* @var string
*/
public $fname;

/**
* Parametry SOAP requestu na server.
* @var array<int, mixed>
*/
public $args;

/**
* Zasobnik volanych funkci.
* @var array<int, array<string, mixed>>
*/
public $trace;

/**
* Doba trvani pozadvku.
* @var float
*/
public $time;

/**
* SOAP response.
* @var mixed
*/
public $result;

private function __construct($fname, $args, $trace, $time, $result)
{
$this->fname = $fname;
$this->args = $args;
$this->trace = $trace;
$this->time = $time;
$this->result = $result;
}

public static function createFromPostEvent(RequestPostEvent $event): SkautisQuery {
return new SkautisQuery($event->getFname(), $event->getArgs(), $event->getTrace(), $event->getDuration(), $event->getResult());
}

public static function createFromFailEvent(RequestFailEvent $event): SkautisQuery {
return new SkautisQuery($event->getFname(), $event->getArgs(), $event->getTrace(), $event->getDuration(), null);
}
}
2 changes: 1 addition & 1 deletion tests/SkautisNette/SkautisExtension.debug.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ else {
}

Assert::true($container->hasService('skautis.skautis'));
Assert::type('Skautis\Skautis', $container->getService('skautis.skautis'));
Assert::type('Skaut\Skautis\Skautis', $container->getService('skautis.skautis'));

if (class_exists('Tracy\Debugger')) {
Assert::true($container->isCreated('skautis.panel'));
Expand Down
2 changes: 1 addition & 1 deletion tests/SkautisNette/SkautisExtension.production.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ $configurator->setDebugMode(FALSE);
$configurator->addConfig(__DIR__ . '/files/config.neon');
$container = $configurator->createContainer();

Assert::type('Skautis\Skautis', $container->getService('skautis.skautis'));
Assert::type('Skaut\Skautis\Skautis', $container->getService('skautis.skautis'));
Assert::false($container->hasService('skautis.panel'));
2 changes: 1 addition & 1 deletion tests/composer-nette-3.0-without-tracy.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"require": {
"php": ">=7.1",
"skautis/skautis": "3.0.0-alpha.1",
"skautis/skautis": "3.0.0-alpha.4",
"nette/di": "^3.0",
"nette/http": "^3.0",
"nette/utils": "^3.0"
Expand Down
2 changes: 1 addition & 1 deletion tests/composer-nette-3.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"require": {
"php": ">=7.1",
"skautis/skautis": "3.0.0-alpha.1",
"skautis/skautis": "3.0.0-alpha.4",
"nette/di": "^3.0",
"nette/http": "^3.0",
"nette/utils": "^3.0"
Expand Down
2 changes: 1 addition & 1 deletion tests/composer-nette-3.1-without-tracy.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"require": {
"php": ">=7.2",
"skautis/skautis": "3.0.0-alpha.1",
"skautis/skautis": "3.0.0-alpha.4",
"nette/di": "^3.0",
"nette/http": "^3.1",
"nette/utils": "^3.1"
Expand Down
2 changes: 1 addition & 1 deletion tests/composer-nette-3.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"require": {
"php": ">=7.2",
"skautis/skautis": "3.0.0-alpha.1",
"skautis/skautis": "3.0.0-alpha.4",
"nette/di": "^3.0",
"nette/http": "^3.1",
"nette/utils": "^3.1"
Expand Down