Skip to content

Commit

Permalink
Replace kdyby/events with contribute/event-dispatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
Frantisek Vesely committed Aug 14, 2017
1 parent a697130 commit ea636c1
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -21,7 +21,7 @@ matrix:

install:
- if [ "$PHPSTAN" = "1" ]; then composer require --dev --no-update phpstan/phpstan-shim:^0.7; fi
- travis_retry composer update --no-interaction --no-suggest --no-progress --prefer-dist --prefer-stable
- travis_retry composer update --no-interaction --no-suggest --no-progress --prefer-dist
- travis_retry composer create-project --no-interaction jakub-onderka/php-parallel-lint /tmp/php-parallel-lint
- if [ "$COVERAGE" != "" ]; then travis_retry wget -O /tmp/coveralls.phar https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar; fi

Expand Down
5 changes: 3 additions & 2 deletions composer.json
Expand Up @@ -14,10 +14,11 @@
},
"require": {
"php": ">=7.1",
"contributte/event-application-bridge": "^0.1.1",
"contributte/event-dispatcher": "^0.3.0",
"doctrine/orm": "^2.5",
"grand-media/security": "@dev",
"kdyby/events": "^3.1",
"kdyby/doctrine": "^3.2",
"kdyby/doctrine": "@dev",
"nette/application": "^2.4",
"nette/di": "^2.4"
},
Expand Down
23 changes: 12 additions & 11 deletions src/Authentication/AutomaticLogoutListener.php
Expand Up @@ -2,10 +2,11 @@

namespace GrandMedia\SecurityDoctrine\Authentication;

use Contributte\Events\Bridges\Application\Event\StartupEvent;
use Doctrine\ORM\EntityNotFoundException;
use GrandMedia\Security\Authentication\AuthenticationManager;

final class AutomaticLogoutListener implements \Kdyby\Events\Subscriber
final class AutomaticLogoutListener implements \Contributte\EventDispatcher\EventSubscriber
{

/** @var \GrandMedia\Security\Authentication\AuthenticationManager */
Expand All @@ -16,6 +17,16 @@ public function __construct(AuthenticationManager $authenticationManager)
$this->authenticationManager = $authenticationManager;
}

/**
* @return string[]
*/
public static function getSubscribedEvents(): array
{
return [
StartupEvent::NAME => 'check',
];
}

public function check(): void
{
try {
Expand All @@ -29,14 +40,4 @@ public function check(): void
}
}

/**
* @return string[]
*/
public function getSubscribedEvents(): array
{
return [
'Nette\Application\Application::onStartup' => 'check',
];
}

}
13 changes: 9 additions & 4 deletions src/DI/SecurityDoctrineExtension.php
Expand Up @@ -2,10 +2,11 @@

namespace GrandMedia\SecurityDoctrine\DI;

use Contributte\EventDispatcher\DI\EventDispatcherExtension;
use Contributte\Events\Bridges\Application\DI\EventApplicationBridgeExtension;
use GrandMedia\Security\DI\SecurityExtension;
use GrandMedia\SecurityDoctrine\Authentication\AutomaticLogoutListener;
use Kdyby\Doctrine\DI\OrmExtension;
use Kdyby\Events\DI\EventsExtension;
use Nette\Utils\AssertionException;

final class SecurityDoctrineExtension extends \Nette\DI\CompilerExtension implements \Kdyby\Doctrine\DI\IEntityProvider
Expand All @@ -16,13 +17,17 @@ public function loadConfiguration(): void
$containerBuilder = $this->getContainerBuilder();

$containerBuilder->addDefinition($this->prefix('automaticLogoutListener'))
->setClass(AutomaticLogoutListener::class)
->addTag(EventsExtension::TAG_SUBSCRIBER);
->setClass(AutomaticLogoutListener::class);
}

public function beforeCompile(): void
{
foreach ([SecurityExtension::class, OrmExtension::class, EventsExtension::class] as $extension) {
foreach ([
SecurityExtension::class,
OrmExtension::class,
EventDispatcherExtension::class,
EventApplicationBridgeExtension::class,
] as $extension) {
if (\count($this->compiler->getExtensions($extension)) === 0) {
throw new AssertionException(\sprintf('Please register the required %s to Compiler.', $extension));
}
Expand Down
19 changes: 10 additions & 9 deletions tests/SecurityDoctrine/DI/config/reset.neon
@@ -1,14 +1,15 @@
php:
date.timezone: Europe/Prague
date.timezone: Europe/Prague

extensions:
- GrandMedia\Security\DI\SecurityExtension
- GrandMedia\SecurityDoctrine\DI\SecurityDoctrineExtension
- Kdyby\Annotations\DI\AnnotationsExtension
- Kdyby\Console\DI\ConsoleExtension
- Kdyby\Events\DI\EventsExtension
doctrine: Kdyby\Doctrine\DI\OrmExtension
- GrandMedia\Security\DI\SecurityExtension
- GrandMedia\SecurityDoctrine\DI\SecurityDoctrineExtension
- Kdyby\Annotations\DI\AnnotationsExtension
- Kdyby\Console\DI\ConsoleExtension
- Contributte\EventDispatcher\DI\EventDispatcherExtension
- Contributte\Events\Bridges\Application\DI\EventApplicationBridgeExtension
doctrine: Kdyby\Doctrine\DI\OrmExtension

doctrine:
driver: pdo_sqlite
memory: true
driver: pdo_sqlite
memory: true

0 comments on commit ea636c1

Please sign in to comment.