Update to Drupal 8.2.6. For more information, see https://www.drupal.org/project/drupal/releases/8.2.6
This commit is contained in:
parent
db56c09587
commit
f1e72395cb
588 changed files with 26857 additions and 2777 deletions
|
@ -104,6 +104,10 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
|
|||
*/
|
||||
public function getListenerPriority($eventName, $listener)
|
||||
{
|
||||
if (!method_exists($this->dispatcher, 'getListenerPriority')) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $this->dispatcher->getListenerPriority($eventName, $listener);
|
||||
}
|
||||
|
||||
|
@ -124,6 +128,10 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
|
|||
$event = new Event();
|
||||
}
|
||||
|
||||
if (null !== $this->logger && $event->isPropagationStopped()) {
|
||||
$this->logger->debug(sprintf('The "%s" event is already stopped. No listeners have been called.', $eventName));
|
||||
}
|
||||
|
||||
$this->preProcess($eventName);
|
||||
$this->preDispatch($eventName, $event);
|
||||
|
||||
|
|
|
@ -97,9 +97,13 @@ class RegisterListenersPass implements CompilerPassInterface
|
|||
|
||||
// We must assume that the class value has been correctly filled, even if the service is created by a factory
|
||||
$class = $container->getParameterBag()->resolveValue($def->getClass());
|
||||
|
||||
$interface = 'Symfony\Component\EventDispatcher\EventSubscriberInterface';
|
||||
|
||||
if (!is_subclass_of($class, $interface)) {
|
||||
if (!class_exists($class, false)) {
|
||||
throw new \InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id));
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface));
|
||||
}
|
||||
|
||||
|
|
6
vendor/symfony/event-dispatcher/Event.php
vendored
6
vendor/symfony/event-dispatcher/Event.php
vendored
|
@ -33,7 +33,7 @@ class Event
|
|||
private $propagationStopped = false;
|
||||
|
||||
/**
|
||||
* @var EventDispatcher Dispatcher that dispatched this event
|
||||
* @var EventDispatcherInterface Dispatcher that dispatched this event
|
||||
*/
|
||||
private $dispatcher;
|
||||
|
||||
|
@ -47,7 +47,7 @@ class Event
|
|||
*
|
||||
* @see Event::stopPropagation()
|
||||
*
|
||||
* @return bool Whether propagation was already stopped for this event.
|
||||
* @return bool Whether propagation was already stopped for this event
|
||||
*/
|
||||
public function isPropagationStopped()
|
||||
{
|
||||
|
@ -109,7 +109,7 @@ class Event
|
|||
/**
|
||||
* Sets the event's name property.
|
||||
*
|
||||
* @param string $name The event name.
|
||||
* @param string $name The event name
|
||||
*
|
||||
* @deprecated since version 2.4, to be removed in 3.0. The event name is passed to the listener call.
|
||||
*/
|
||||
|
|
|
@ -92,7 +92,7 @@ class EventDispatcher implements EventDispatcherInterface
|
|||
}
|
||||
|
||||
foreach ($this->listeners[$eventName] as $priority => $listeners) {
|
||||
if (false !== ($key = array_search($listener, $listeners, true))) {
|
||||
if (false !== in_array($listener, $listeners, true)) {
|
||||
return $priority;
|
||||
}
|
||||
}
|
||||
|
@ -171,24 +171,24 @@ class EventDispatcher implements EventDispatcherInterface
|
|||
* This method can be overridden to add functionality that is executed
|
||||
* for each listener.
|
||||
*
|
||||
* @param callable[] $listeners The event listeners.
|
||||
* @param string $eventName The name of the event to dispatch.
|
||||
* @param Event $event The event object to pass to the event handlers/listeners.
|
||||
* @param callable[] $listeners The event listeners
|
||||
* @param string $eventName The name of the event to dispatch
|
||||
* @param Event $event The event object to pass to the event handlers/listeners
|
||||
*/
|
||||
protected function doDispatch($listeners, $eventName, Event $event)
|
||||
{
|
||||
foreach ($listeners as $listener) {
|
||||
call_user_func($listener, $event, $eventName, $this);
|
||||
if ($event->isPropagationStopped()) {
|
||||
break;
|
||||
}
|
||||
call_user_func($listener, $event, $eventName, $this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the internal list of listeners for the given event by priority.
|
||||
*
|
||||
* @param string $eventName The name of the event.
|
||||
* @param string $eventName The name of the event
|
||||
*/
|
||||
private function sortListeners($eventName)
|
||||
{
|
||||
|
|
|
@ -26,7 +26,7 @@ interface EventDispatcherInterface
|
|||
* @param string $eventName The name of the event to dispatch. The name of
|
||||
* the event is the name of the method that is
|
||||
* invoked on listeners.
|
||||
* @param Event $event The event to pass to the event handlers/listeners.
|
||||
* @param Event $event The event to pass to the event handlers/listeners
|
||||
* If not supplied, an empty Event instance is created.
|
||||
*
|
||||
* @return Event
|
||||
|
@ -49,7 +49,7 @@ interface EventDispatcherInterface
|
|||
* The subscriber is asked for all the events he is
|
||||
* interested in and added as a listener for these events.
|
||||
*
|
||||
* @param EventSubscriberInterface $subscriber The subscriber.
|
||||
* @param EventSubscriberInterface $subscriber The subscriber
|
||||
*/
|
||||
public function addSubscriber(EventSubscriberInterface $subscriber);
|
||||
|
||||
|
|
38
vendor/symfony/event-dispatcher/GenericEvent.php
vendored
38
vendor/symfony/event-dispatcher/GenericEvent.php
vendored
|
@ -37,8 +37,8 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
|
|||
/**
|
||||
* Encapsulate an event with $subject and $args.
|
||||
*
|
||||
* @param mixed $subject The subject of the event, usually an object.
|
||||
* @param array $arguments Arguments to store in the event.
|
||||
* @param mixed $subject The subject of the event, usually an object
|
||||
* @param array $arguments Arguments to store in the event
|
||||
*/
|
||||
public function __construct($subject = null, array $arguments = array())
|
||||
{
|
||||
|
@ -49,7 +49,7 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
|
|||
/**
|
||||
* Getter for subject property.
|
||||
*
|
||||
* @return mixed $subject The observer subject.
|
||||
* @return mixed $subject The observer subject
|
||||
*/
|
||||
public function getSubject()
|
||||
{
|
||||
|
@ -59,11 +59,11 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
|
|||
/**
|
||||
* Get argument by key.
|
||||
*
|
||||
* @param string $key Key.
|
||||
* @param string $key Key
|
||||
*
|
||||
* @return mixed Contents of array key
|
||||
*
|
||||
* @throws \InvalidArgumentException If key is not found.
|
||||
*
|
||||
* @return mixed Contents of array key.
|
||||
*/
|
||||
public function getArgument($key)
|
||||
{
|
||||
|
@ -77,10 +77,10 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
|
|||
/**
|
||||
* Add argument to event.
|
||||
*
|
||||
* @param string $key Argument name.
|
||||
* @param mixed $value Value.
|
||||
* @param string $key Argument name
|
||||
* @param mixed $value Value
|
||||
*
|
||||
* @return GenericEvent
|
||||
* @return $this
|
||||
*/
|
||||
public function setArgument($key, $value)
|
||||
{
|
||||
|
@ -102,9 +102,9 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
|
|||
/**
|
||||
* Set args property.
|
||||
*
|
||||
* @param array $args Arguments.
|
||||
* @param array $args Arguments
|
||||
*
|
||||
* @return GenericEvent
|
||||
* @return $this
|
||||
*/
|
||||
public function setArguments(array $args = array())
|
||||
{
|
||||
|
@ -116,7 +116,7 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
|
|||
/**
|
||||
* Has argument.
|
||||
*
|
||||
* @param string $key Key of arguments array.
|
||||
* @param string $key Key of arguments array
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
@ -128,11 +128,11 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
|
|||
/**
|
||||
* ArrayAccess for argument getter.
|
||||
*
|
||||
* @param string $key Array key.
|
||||
*
|
||||
* @throws \InvalidArgumentException If key does not exist in $this->args.
|
||||
* @param string $key Array key
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \InvalidArgumentException If key does not exist in $this->args.
|
||||
*/
|
||||
public function offsetGet($key)
|
||||
{
|
||||
|
@ -142,8 +142,8 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
|
|||
/**
|
||||
* ArrayAccess for argument setter.
|
||||
*
|
||||
* @param string $key Array key to set.
|
||||
* @param mixed $value Value.
|
||||
* @param string $key Array key to set
|
||||
* @param mixed $value Value
|
||||
*/
|
||||
public function offsetSet($key, $value)
|
||||
{
|
||||
|
@ -153,7 +153,7 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
|
|||
/**
|
||||
* ArrayAccess for unset argument.
|
||||
*
|
||||
* @param string $key Array key.
|
||||
* @param string $key Array key
|
||||
*/
|
||||
public function offsetUnset($key)
|
||||
{
|
||||
|
@ -165,7 +165,7 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
|
|||
/**
|
||||
* ArrayAccess has argument.
|
||||
*
|
||||
* @param string $key Array key.
|
||||
* @param string $key Array key
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
|
|
@ -28,7 +28,7 @@ class ImmutableEventDispatcher implements EventDispatcherInterface
|
|||
/**
|
||||
* Creates an unmodifiable proxy for an event dispatcher.
|
||||
*
|
||||
* @param EventDispatcherInterface $dispatcher The proxied event dispatcher.
|
||||
* @param EventDispatcherInterface $dispatcher The proxied event dispatcher
|
||||
*/
|
||||
public function __construct(EventDispatcherInterface $dispatcher)
|
||||
{
|
||||
|
|
2
vendor/symfony/event-dispatcher/LICENSE
vendored
2
vendor/symfony/event-dispatcher/LICENSE
vendored
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2004-2016 Fabien Potencier
|
||||
Copyright (c) 2004-2017 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -142,7 +142,7 @@ abstract class AbstractEventDispatcherTest extends \PHPUnit_Framework_TestCase
|
|||
public function testLegacyDispatch()
|
||||
{
|
||||
$event = new Event();
|
||||
$return = $this->dispatcher->dispatch(self::preFoo, $event);
|
||||
$this->dispatcher->dispatch(self::preFoo, $event);
|
||||
$this->assertEquals('pre.foo', $event->getName());
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
|
|||
{
|
||||
$event = new Event();
|
||||
|
||||
$service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
|
||||
$service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
|
||||
|
||||
$service
|
||||
->expects($this->once())
|
||||
|
@ -51,7 +51,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
|
|||
{
|
||||
$event = new Event();
|
||||
|
||||
$service = $this->getMock('Symfony\Component\EventDispatcher\Tests\SubscriberService');
|
||||
$service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\SubscriberService')->getMock();
|
||||
|
||||
$service
|
||||
->expects($this->once())
|
||||
|
@ -86,7 +86,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
|
|||
{
|
||||
$event = new Event();
|
||||
|
||||
$service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
|
||||
$service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
|
||||
|
||||
$service
|
||||
->expects($this->once())
|
||||
|
@ -110,7 +110,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
|
|||
*/
|
||||
public function testTriggerAListenerServiceOutOfScope()
|
||||
{
|
||||
$service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
|
||||
$service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
|
||||
|
||||
$scope = new Scope('scope');
|
||||
$container = new Container();
|
||||
|
@ -133,7 +133,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
|
|||
{
|
||||
$event = new Event();
|
||||
|
||||
$service1 = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
|
||||
$service1 = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
|
||||
|
||||
$service1
|
||||
->expects($this->exactly(2))
|
||||
|
@ -152,7 +152,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
|
|||
$dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
|
||||
$dispatcher->dispatch('onEvent', $event);
|
||||
|
||||
$service2 = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
|
||||
$service2 = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
|
||||
|
||||
$service2
|
||||
->expects($this->once())
|
||||
|
@ -174,7 +174,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
|
|||
{
|
||||
$event = new Event();
|
||||
|
||||
$service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
|
||||
$service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
|
||||
|
||||
$container = new Container();
|
||||
$container->set('service.listener', $service);
|
||||
|
@ -200,7 +200,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
|
|||
|
||||
public function testGetListenersOnLazyLoad()
|
||||
{
|
||||
$service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
|
||||
$service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
|
||||
|
||||
$container = new Container();
|
||||
$container->set('service.listener', $service);
|
||||
|
@ -217,7 +217,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
|
|||
|
||||
public function testRemoveAfterDispatch()
|
||||
{
|
||||
$service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
|
||||
$service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
|
||||
|
||||
$container = new Container();
|
||||
$container->set('service.listener', $service);
|
||||
|
@ -232,7 +232,7 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
|
|||
|
||||
public function testRemoveBeforeDispatch()
|
||||
{
|
||||
$service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
|
||||
$service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
|
||||
|
||||
$container = new Container();
|
||||
$container->set('service.listener', $service);
|
||||
|
|
|
@ -73,6 +73,16 @@ class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertSame(123, $tdispatcher->getListenerPriority('foo', $listeners[0]));
|
||||
}
|
||||
|
||||
public function testGetListenerPriorityReturnsZeroWhenWrappedMethodDoesNotExist()
|
||||
{
|
||||
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
|
||||
$traceableEventDispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch());
|
||||
$traceableEventDispatcher->addListener('foo', function () {}, 123);
|
||||
$listeners = $traceableEventDispatcher->getListeners('foo');
|
||||
|
||||
$this->assertSame(0, $traceableEventDispatcher->getListenerPriority('foo', $listeners[0]));
|
||||
}
|
||||
|
||||
public function testAddRemoveSubscriber()
|
||||
{
|
||||
$dispatcher = new EventDispatcher();
|
||||
|
@ -120,7 +130,7 @@ class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testLogger()
|
||||
{
|
||||
$logger = $this->getMock('Psr\Log\LoggerInterface');
|
||||
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
|
||||
|
||||
$dispatcher = new EventDispatcher();
|
||||
$tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger);
|
||||
|
@ -135,7 +145,7 @@ class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testLoggerWithStoppedEvent()
|
||||
{
|
||||
$logger = $this->getMock('Psr\Log\LoggerInterface');
|
||||
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
|
||||
|
||||
$dispatcher = new EventDispatcher();
|
||||
$tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger);
|
||||
|
|
|
@ -29,7 +29,7 @@ class RegisterListenersPassTest extends \PHPUnit_Framework_TestCase
|
|||
'my_event_subscriber' => array(0 => array()),
|
||||
);
|
||||
|
||||
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
|
||||
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
|
||||
$definition->expects($this->atLeastOnce())
|
||||
->method('isPublic')
|
||||
->will($this->returnValue(true));
|
||||
|
@ -37,10 +37,7 @@ class RegisterListenersPassTest extends \PHPUnit_Framework_TestCase
|
|||
->method('getClass')
|
||||
->will($this->returnValue('stdClass'));
|
||||
|
||||
$builder = $this->getMock(
|
||||
'Symfony\Component\DependencyInjection\ContainerBuilder',
|
||||
array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
|
||||
);
|
||||
$builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
|
||||
$builder->expects($this->any())
|
||||
->method('hasDefinition')
|
||||
->will($this->returnValue(true));
|
||||
|
@ -64,7 +61,7 @@ class RegisterListenersPassTest extends \PHPUnit_Framework_TestCase
|
|||
'my_event_subscriber' => array(0 => array()),
|
||||
);
|
||||
|
||||
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
|
||||
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
|
||||
$definition->expects($this->atLeastOnce())
|
||||
->method('isPublic')
|
||||
->will($this->returnValue(true));
|
||||
|
@ -72,10 +69,7 @@ class RegisterListenersPassTest extends \PHPUnit_Framework_TestCase
|
|||
->method('getClass')
|
||||
->will($this->returnValue('Symfony\Component\EventDispatcher\Tests\DependencyInjection\SubscriberService'));
|
||||
|
||||
$builder = $this->getMock(
|
||||
'Symfony\Component\DependencyInjection\ContainerBuilder',
|
||||
array('hasDefinition', 'findTaggedServiceIds', 'getDefinition', 'findDefinition')
|
||||
);
|
||||
$builder = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition', 'findDefinition'))->getMock();
|
||||
$builder->expects($this->any())
|
||||
->method('hasDefinition')
|
||||
->will($this->returnValue(true));
|
||||
|
|
|
@ -31,7 +31,7 @@ class ImmutableEventDispatcherTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->innerDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
|
||||
$this->innerDispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
|
||||
$this->dispatcher = new ImmutableEventDispatcher($this->innerDispatcher);
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ class ImmutableEventDispatcherTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testAddSubscriberDisallowed()
|
||||
{
|
||||
$subscriber = $this->getMock('Symfony\Component\EventDispatcher\EventSubscriberInterface');
|
||||
$subscriber = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventSubscriberInterface')->getMock();
|
||||
|
||||
$this->dispatcher->addSubscriber($subscriber);
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ class ImmutableEventDispatcherTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testRemoveSubscriberDisallowed()
|
||||
{
|
||||
$subscriber = $this->getMock('Symfony\Component\EventDispatcher\EventSubscriberInterface');
|
||||
$subscriber = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventSubscriberInterface')->getMock();
|
||||
|
||||
$this->dispatcher->removeSubscriber($subscriber);
|
||||
}
|
||||
|
|
Reference in a new issue