Skip to content

Commit

Permalink
use psr event dispatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
alekitto committed Jun 16, 2019
1 parent 564e193 commit 46b94ce
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
5 changes: 1 addition & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@
"doctrine/cache": "^1.4",
"mikey179/vfsstream": "^1.6",
"phpunit/phpunit": "^8.0",
"psr/event-dispatcher": "^1.0",
"symfony/cache": "^4.3",
"symfony/event-dispatcher": "^4.3",
"symfony/finder": "^4.3"
},
"conflict": {
"symfony/event-dispatcher": "<4.3"
},
"suggest": {
"symfony/cache": "cache metadata",
"symfony/event-dispatcher": "dispatch metadata load event",
Expand Down
25 changes: 23 additions & 2 deletions lib/Event/ClassMetadataLoadedEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
namespace Kcs\Metadata\Event;

use Kcs\Metadata\ClassMetadataInterface;
use Symfony\Contracts\EventDispatcher\Event;
use Psr\EventDispatcher\StoppableEventInterface;

class ClassMetadataLoadedEvent extends Event
class ClassMetadataLoadedEvent implements StoppableEventInterface
{
/**
* @var bool
*/
private $propagationStopped = false;

/**
* @var ClassMetadataInterface
*/
Expand All @@ -24,4 +29,20 @@ public function getMetadata(): ClassMetadataInterface
{
return $this->metadata;
}

/**
* {@inheritdoc}
*/
public function isPropagationStopped(): bool
{
return $this->propagationStopped;
}

/**
* Stops the propagation of the event to further event listeners.
*/
public function stopPropagation(): void
{
$this->propagationStopped = true;
}
}
2 changes: 1 addition & 1 deletion lib/Factory/AbstractMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Kcs\Metadata\Exception\InvalidMetadataException;
use Kcs\Metadata\Loader\LoaderInterface;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Psr\EventDispatcher\EventDispatcherInterface;

abstract class AbstractMetadataFactory implements MetadataFactoryInterface
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Factory/MetadataFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
use Prophecy\Argument;
use Prophecy\Prophecy\ObjectProphecy;
use Psr\Cache\CacheItemPoolInterface;
use Psr\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Contracts\Cache\ItemInterface;

class MockedClassMetadataFactory extends MetadataFactory
Expand Down

0 comments on commit 46b94ce

Please sign in to comment.