Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
SIPSB-SMA2-Balige
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PA2-D3TI02-1617
SIPSB-SMA2-Balige
Commits
e089db31
Commit
e089db31
authored
May 31, 2017
by
Hartanti\Tanti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
a286ee8a
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
3 additions
and
2592 deletions
+3
-2592
app.php
config/app.php
+3
-1
.gitignore
vendor/symfony/event-dispatcher/.gitignore
+0
-3
CHANGELOG.md
vendor/symfony/event-dispatcher/CHANGELOG.md
+0
-32
ContainerAwareEventDispatcher.php
...ymfony/event-dispatcher/ContainerAwareEventDispatcher.php
+0
-195
TraceableEventDispatcher.php
...mfony/event-dispatcher/Debug/TraceableEventDispatcher.php
+0
-324
TraceableEventDispatcherInterface.php
...nt-dispatcher/Debug/TraceableEventDispatcherInterface.php
+0
-34
WrappedListener.php
vendor/symfony/event-dispatcher/Debug/WrappedListener.php
+0
-116
RegisterListenersPass.php
...-dispatcher/DependencyInjection/RegisterListenersPass.php
+0
-114
Event.php
vendor/symfony/event-dispatcher/Event.php
+0
-58
EventDispatcher.php
vendor/symfony/event-dispatcher/EventDispatcher.php
+0
-188
EventDispatcherInterface.php
vendor/symfony/event-dispatcher/EventDispatcherInterface.php
+0
-100
EventSubscriberInterface.php
vendor/symfony/event-dispatcher/EventSubscriberInterface.php
+0
-46
GenericEvent.php
vendor/symfony/event-dispatcher/GenericEvent.php
+0
-186
ImmutableEventDispatcher.php
vendor/symfony/event-dispatcher/ImmutableEventDispatcher.php
+0
-101
LICENSE
vendor/symfony/event-dispatcher/LICENSE
+0
-19
README.md
vendor/symfony/event-dispatcher/README.md
+0
-15
AbstractEventDispatcherTest.php
...ny/event-dispatcher/Tests/AbstractEventDispatcherTest.php
+0
-0
ContainerAwareEventDispatcherTest.php
...nt-dispatcher/Tests/ContainerAwareEventDispatcherTest.php
+0
-207
TraceableEventDispatcherTest.php
...t-dispatcher/Tests/Debug/TraceableEventDispatcherTest.php
+0
-260
RegisterListenersPassTest.php
...r/Tests/DependencyInjection/RegisterListenersPassTest.php
+0
-195
EventDispatcherTest.php
...or/symfony/event-dispatcher/Tests/EventDispatcherTest.php
+0
-22
EventTest.php
vendor/symfony/event-dispatcher/Tests/EventTest.php
+0
-55
GenericEventTest.php
vendor/symfony/event-dispatcher/Tests/GenericEventTest.php
+0
-140
ImmutableEventDispatcherTest.php
...y/event-dispatcher/Tests/ImmutableEventDispatcherTest.php
+0
-106
composer.json
vendor/symfony/event-dispatcher/composer.json
+0
-44
phpunit.xml.dist
vendor/symfony/event-dispatcher/phpunit.xml.dist
+0
-31
No files found.
config/app.php
View file @
e089db31
...
...
@@ -177,7 +177,8 @@ return [
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider
::
class
,
App\Providers\RouteServiceProvider
::
class
,
Collective\Html\HtmlServiceProvider
::
class
Collective\Html\HtmlServiceProvider
::
class
,
Barryvdh\DomPDF\serviceProvider
::
class
,
],
...
...
@@ -228,6 +229,7 @@ return [
'View'
=>
Illuminate\Support\Facades\View
::
class
,
'Form'
=>
Collective\Html\FormFacade
::
class
,
'Html'
=>
Collective\Html\HtmlFacade
::
class
,
'PDF'
=>
Barryvdh\DomPDF\Facade
::
class
,
],
...
...
vendor/symfony/event-dispatcher/.gitignore
deleted
100644 → 0
View file @
a286ee8a
vendor/
composer.lock
phpunit.xml
vendor/symfony/event-dispatcher/CHANGELOG.md
deleted
100644 → 0
View file @
a286ee8a
CHANGELOG
=========
3.
0.0
-----
*
The method
`getListenerPriority($eventName, $listener)`
has been added to the
`EventDispatcherInterface`
.
*
The methods
`Event::setDispatcher()`
,
`Event::getDispatcher()`
,
`Event::setName()`
and
`Event::getName()`
have been removed.
The event dispatcher and the event name are passed to the listener call.
2.
5.0
-----
*
added Debug
\T
raceableEventDispatcher (originally in HttpKernel)
*
changed Debug
\T
raceableEventDispatcherInterface to extend EventDispatcherInterface
*
added RegisterListenersPass (originally in HttpKernel)
2.
1.0
-----
*
added TraceableEventDispatcherInterface
*
added ContainerAwareEventDispatcher
*
added a reference to the EventDispatcher on the Event
*
added a reference to the Event name on the event
*
added fluid interface to the dispatch() method which now returns the Event
object
*
added GenericEvent event class
*
added the possibility for subscribers to subscribe several times for the
same event
*
added ImmutableEventDispatcher
vendor/symfony/event-dispatcher/ContainerAwareEventDispatcher.php
deleted
100644 → 0
View file @
a286ee8a
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Symfony\Component\EventDispatcher
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
* Lazily loads listeners and subscribers from the dependency injection
* container.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Bernhard Schussek <bschussek@gmail.com>
* @author Jordan Alliot <jordan.alliot@gmail.com>
*/
class
ContainerAwareEventDispatcher
extends
EventDispatcher
{
/**
* The container from where services are loaded.
*
* @var ContainerInterface
*/
private
$container
;
/**
* The service IDs of the event listeners and subscribers.
*
* @var array
*/
private
$listenerIds
=
array
();
/**
* The services registered as listeners.
*
* @var array
*/
private
$listeners
=
array
();
/**
* Constructor.
*
* @param ContainerInterface $container A ContainerInterface instance
*/
public
function
__construct
(
ContainerInterface
$container
)
{
$this
->
container
=
$container
;
}
/**
* Adds a service as event listener.
*
* @param string $eventName Event for which the listener is added
* @param array $callback The service ID of the listener service & the method
* name that has to be called
* @param int $priority The higher this value, the earlier an event listener
* will be triggered in the chain.
* Defaults to 0.
*
* @throws \InvalidArgumentException
*/
public
function
addListenerService
(
$eventName
,
$callback
,
$priority
=
0
)
{
if
(
!
is_array
(
$callback
)
||
2
!==
count
(
$callback
))
{
throw
new
\InvalidArgumentException
(
'Expected an array("service", "method") argument'
);
}
$this
->
listenerIds
[
$eventName
][]
=
array
(
$callback
[
0
],
$callback
[
1
],
$priority
);
}
public
function
removeListener
(
$eventName
,
$listener
)
{
$this
->
lazyLoad
(
$eventName
);
if
(
isset
(
$this
->
listenerIds
[
$eventName
]))
{
foreach
(
$this
->
listenerIds
[
$eventName
]
as
$i
=>
list
(
$serviceId
,
$method
,
$priority
))
{
$key
=
$serviceId
.
'.'
.
$method
;
if
(
isset
(
$this
->
listeners
[
$eventName
][
$key
])
&&
$listener
===
array
(
$this
->
listeners
[
$eventName
][
$key
],
$method
))
{
unset
(
$this
->
listeners
[
$eventName
][
$key
]);
if
(
empty
(
$this
->
listeners
[
$eventName
]))
{
unset
(
$this
->
listeners
[
$eventName
]);
}
unset
(
$this
->
listenerIds
[
$eventName
][
$i
]);
if
(
empty
(
$this
->
listenerIds
[
$eventName
]))
{
unset
(
$this
->
listenerIds
[
$eventName
]);
}
}
}
}
parent
::
removeListener
(
$eventName
,
$listener
);
}
/**
* {@inheritdoc}
*/
public
function
hasListeners
(
$eventName
=
null
)
{
if
(
null
===
$eventName
)
{
return
(
bool
)
count
(
$this
->
listenerIds
)
||
(
bool
)
count
(
$this
->
listeners
);
}
if
(
isset
(
$this
->
listenerIds
[
$eventName
]))
{
return
true
;
}
return
parent
::
hasListeners
(
$eventName
);
}
/**
* {@inheritdoc}
*/
public
function
getListeners
(
$eventName
=
null
)
{
if
(
null
===
$eventName
)
{
foreach
(
$this
->
listenerIds
as
$serviceEventName
=>
$args
)
{
$this
->
lazyLoad
(
$serviceEventName
);
}
}
else
{
$this
->
lazyLoad
(
$eventName
);
}
return
parent
::
getListeners
(
$eventName
);
}
/**
* {@inheritdoc}
*/
public
function
getListenerPriority
(
$eventName
,
$listener
)
{
$this
->
lazyLoad
(
$eventName
);
return
parent
::
getListenerPriority
(
$eventName
,
$listener
);
}
/**
* Adds a service as event subscriber.
*
* @param string $serviceId The service ID of the subscriber service
* @param string $class The service's class name (which must implement EventSubscriberInterface)
*/
public
function
addSubscriberService
(
$serviceId
,
$class
)
{
foreach
(
$class
::
getSubscribedEvents
()
as
$eventName
=>
$params
)
{
if
(
is_string
(
$params
))
{
$this
->
listenerIds
[
$eventName
][]
=
array
(
$serviceId
,
$params
,
0
);
}
elseif
(
is_string
(
$params
[
0
]))
{
$this
->
listenerIds
[
$eventName
][]
=
array
(
$serviceId
,
$params
[
0
],
isset
(
$params
[
1
])
?
$params
[
1
]
:
0
);
}
else
{
foreach
(
$params
as
$listener
)
{
$this
->
listenerIds
[
$eventName
][]
=
array
(
$serviceId
,
$listener
[
0
],
isset
(
$listener
[
1
])
?
$listener
[
1
]
:
0
);
}
}
}
}
public
function
getContainer
()
{
return
$this
->
container
;
}
/**
* Lazily loads listeners for this event from the dependency injection
* container.
*
* @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.
*/
protected
function
lazyLoad
(
$eventName
)
{
if
(
isset
(
$this
->
listenerIds
[
$eventName
]))
{
foreach
(
$this
->
listenerIds
[
$eventName
]
as
list
(
$serviceId
,
$method
,
$priority
))
{
$listener
=
$this
->
container
->
get
(
$serviceId
);
$key
=
$serviceId
.
'.'
.
$method
;
if
(
!
isset
(
$this
->
listeners
[
$eventName
][
$key
]))
{
$this
->
addListener
(
$eventName
,
array
(
$listener
,
$method
),
$priority
);
}
elseif
(
$listener
!==
$this
->
listeners
[
$eventName
][
$key
])
{
parent
::
removeListener
(
$eventName
,
array
(
$this
->
listeners
[
$eventName
][
$key
],
$method
));
$this
->
addListener
(
$eventName
,
array
(
$listener
,
$method
),
$priority
);
}
$this
->
listeners
[
$eventName
][
$key
]
=
$listener
;
}
}
}
}
vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php
deleted
100644 → 0
View file @
a286ee8a
This diff is collapsed.
Click to expand it.
vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcherInterface.php
deleted
100644 → 0
View file @
a286ee8a
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Symfony\Component\EventDispatcher\Debug
;
use
Symfony\Component\EventDispatcher\EventDispatcherInterface
;
/**
* @author Fabien Potencier <fabien@symfony.com>
*/
interface
TraceableEventDispatcherInterface
extends
EventDispatcherInterface
{
/**
* Gets the called listeners.
*
* @return array An array of called listeners
*/
public
function
getCalledListeners
();
/**
* Gets the not called listeners.
*
* @return array An array of not called listeners
*/
public
function
getNotCalledListeners
();
}
vendor/symfony/event-dispatcher/Debug/WrappedListener.php
deleted
100644 → 0
View file @
a286ee8a
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Symfony\Component\EventDispatcher\Debug
;
use
Symfony\Component\Stopwatch\Stopwatch
;
use
Symfony\Component\EventDispatcher\Event
;
use
Symfony\Component\EventDispatcher\EventDispatcherInterface
;
use
Symfony\Component\VarDumper\Caster\ClassStub
;
use
Symfony\Component\VarDumper\Cloner\VarCloner
;
/**
* @author Fabien Potencier <fabien@symfony.com>
*/
class
WrappedListener
{
private
$listener
;
private
$name
;
private
$called
;
private
$stoppedPropagation
;
private
$stopwatch
;
private
$dispatcher
;
private
$pretty
;
private
$data
;
private
static
$cloner
;
public
function
__construct
(
$listener
,
$name
,
Stopwatch
$stopwatch
,
EventDispatcherInterface
$dispatcher
=
null
)
{
$this
->
listener
=
$listener
;
$this
->
name
=
$name
;
$this
->
stopwatch
=
$stopwatch
;
$this
->
dispatcher
=
$dispatcher
;
$this
->
called
=
false
;
$this
->
stoppedPropagation
=
false
;
if
(
is_array
(
$listener
))
{
$this
->
name
=
is_object
(
$listener
[
0
])
?
get_class
(
$listener
[
0
])
:
$listener
[
0
];
$this
->
pretty
=
$this
->
name
.
'::'
.
$listener
[
1
];
}
elseif
(
$listener
instanceof
\Closure
)
{
$this
->
pretty
=
$this
->
name
=
'closure'
;
}
elseif
(
is_string
(
$listener
))
{
$this
->
pretty
=
$this
->
name
=
$listener
;
}
else
{
$this
->
name
=
get_class
(
$listener
);
$this
->
pretty
=
$this
->
name
.
'::__invoke'
;
}
if
(
null
!==
$name
)
{
$this
->
name
=
$name
;
}
if
(
null
===
self
::
$cloner
)
{
self
::
$cloner
=
class_exists
(
ClassStub
::
class
)
?
new
VarCloner
()
:
false
;
}
}
public
function
getWrappedListener
()
{
return
$this
->
listener
;
}
public
function
wasCalled
()
{
return
$this
->
called
;
}
public
function
stoppedPropagation
()
{
return
$this
->
stoppedPropagation
;
}
public
function
getPretty
()
{
return
$this
->
pretty
;
}
public
function
getInfo
(
$eventName
)
{
if
(
null
===
$this
->
data
)
{
$this
->
data
=
false
!==
self
::
$cloner
?
self
::
$cloner
->
cloneVar
(
array
(
new
ClassStub
(
$this
->
pretty
.
'()'
,
$this
->
listener
)))
->
seek
(
0
)
:
$this
->
pretty
;
}
return
array
(
'event'
=>
$eventName
,
'priority'
=>
null
!==
$this
->
dispatcher
?
$this
->
dispatcher
->
getListenerPriority
(
$eventName
,
$this
->
listener
)
:
null
,
'pretty'
=>
$this
->
pretty
,
'data'
=>
$this
->
data
,
);
}
public
function
__invoke
(
Event
$event
,
$eventName
,
EventDispatcherInterface
$dispatcher
)
{
$this
->
called
=
true
;
$e
=
$this
->
stopwatch
->
start
(
$this
->
name
,
'event_listener'
);
call_user_func
(
$this
->
listener
,
$event
,
$eventName
,
$this
->
dispatcher
?:
$dispatcher
);
if
(
$e
->
isStarted
())
{
$e
->
stop
();
}
if
(
$event
->
isPropagationStopped
())
{
$this
->
stoppedPropagation
=
true
;
}
}
}
vendor/symfony/event-dispatcher/DependencyInjection/RegisterListenersPass.php
deleted
100644 → 0
View file @
a286ee8a
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Symfony\Component\EventDispatcher\DependencyInjection
;
use
Symfony\Component\DependencyInjection\ContainerBuilder
;
use
Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface
;
use
Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
;
/**
* Compiler pass to register tagged services for an event dispatcher.
*/
class
RegisterListenersPass
implements
CompilerPassInterface
{
/**
* @var string
*/
protected
$dispatcherService
;
/**
* @var string
*/
protected
$listenerTag
;
/**
* @var string
*/
protected
$subscriberTag
;
/**
* Constructor.
*
* @param string $dispatcherService Service name of the event dispatcher in processed container
* @param string $listenerTag Tag name used for listener
* @param string $subscriberTag Tag name used for subscribers
*/
public
function
__construct
(
$dispatcherService
=
'event_dispatcher'
,
$listenerTag
=
'kernel.event_listener'
,
$subscriberTag
=
'kernel.event_subscriber'
)
{
$this
->
dispatcherService
=
$dispatcherService
;
$this
->
listenerTag
=
$listenerTag
;
$this
->
subscriberTag
=
$subscriberTag
;
}
public
function
process
(
ContainerBuilder
$container
)
{
if
(
!
$container
->
hasDefinition
(
$this
->
dispatcherService
)
&&
!
$container
->
hasAlias
(
$this
->
dispatcherService
))
{
return
;
}
$definition
=
$container
->
findDefinition
(
$this
->
dispatcherService
);
foreach
(
$container
->
findTaggedServiceIds
(
$this
->
listenerTag
)
as
$id
=>
$events
)
{
$def
=
$container
->
getDefinition
(
$id
);
if
(
!
$def
->
isPublic
())
{
throw
new
InvalidArgumentException
(
sprintf
(
'The service "%s" must be public as event listeners are lazy-loaded.'
,
$id
));
}
if
(
$def
->
isAbstract
())
{
throw
new
InvalidArgumentException
(
sprintf
(
'The service "%s" must not be abstract as event listeners are lazy-loaded.'
,
$id
));
}
foreach
(
$events
as
$event
)
{
$priority
=
isset
(
$event
[
'priority'
])
?
$event
[
'priority'
]
:
0
;
if
(
!
isset
(
$event
[
'event'
]))
{
throw
new
InvalidArgumentException
(
sprintf
(
'Service "%s" must define the "event" attribute on "%s" tags.'
,
$id
,
$this
->
listenerTag
));
}
if
(
!
isset
(
$event
[
'method'
]))
{
$event
[
'method'
]
=
'on'
.
preg_replace_callback
(
array
(
'/(?<=\b)[a-z]/i'
,
'/[^a-z0-9]/i'
,
),
function
(
$matches
)
{
return
strtoupper
(
$matches
[
0
]);
},
$event
[
'event'
]);
$event
[
'method'
]
=
preg_replace
(
'/[^a-z0-9]/i'
,
''
,
$event
[
'method'
]);
}
$definition
->
addMethodCall
(
'addListenerService'
,
array
(
$event
[
'event'
],
array
(
$id
,
$event
[
'method'
]),
$priority
));
}
}
foreach
(
$container
->
findTaggedServiceIds
(
$this
->
subscriberTag
)
as
$id
=>
$attributes
)
{
$def
=
$container
->
getDefinition
(
$id
);
if
(
!
$def
->
isPublic
())
{
throw
new
InvalidArgumentException
(
sprintf
(
'The service "%s" must be public as event subscribers are lazy-loaded.'
,
$id
));
}
if
(
$def
->
isAbstract
())
{
throw
new
InvalidArgumentException
(
sprintf
(
'The service "%s" must not be abstract as event subscribers are lazy-loaded.'
,
$id
));
}
// 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
));
}
$definition
->
addMethodCall
(
'addSubscriberService'
,
array
(
$id
,
$class
));
}
}
}
vendor/symfony/event-dispatcher/Event.php
deleted
100644 → 0
View file @
a286ee8a
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Symfony\Component\EventDispatcher
;
/**
* Event is the base class for classes containing event data.
*
* This class contains no event data. It is used by events that do not pass
* state information to an event handler when an event is raised.
*
* You can call the method stopPropagation() to abort the execution of
* further listeners in your event listener.
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class
Event
{
/**
* @var bool Whether no further event listeners should be triggered
*/
private
$propagationStopped
=
false
;
/**
* Returns whether further event listeners should be triggered.
*
* @see Event::stopPropagation()
*
* @return bool Whether propagation was already stopped for this event
*/
public
function
isPropagationStopped
()
{
return
$this
->
propagationStopped
;
}
/**
* Stops the propagation of the event to further event listeners.
*
* If multiple event listeners are connected to the same event, no
* further event listener will be triggered once any trigger calls
* stopPropagation().
*/
public
function
stopPropagation
()
{
$this
->
propagationStopped
=
true
;
}
}
vendor/symfony/event-dispatcher/EventDispatcher.php
deleted
100644 → 0
View file @
a286ee8a
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Symfony\Component\EventDispatcher
;
/**
* The EventDispatcherInterface is the central point of Symfony's event listener system.
*
* Listeners are registered on the manager and events are dispatched through the
* manager.
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Bernhard Schussek <bschussek@gmail.com>
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @author Jordan Alliot <jordan.alliot@gmail.com>
*/
class
EventDispatcher
implements
EventDispatcherInterface
{
private
$listeners
=
array
();
private
$sorted
=
array
();
/**
* {@inheritdoc}
*/
public
function
dispatch
(
$eventName
,
Event
$event
=
null
)
{
if
(
null
===
$event
)
{
$event
=
new
Event
();
}
if
(
$listeners
=
$this
->
getListeners
(
$eventName
))
{
$this
->
doDispatch
(
$listeners
,
$eventName
,
$event
);
}
return
$event
;
}
/**
* {@inheritdoc}
*/
public
function
getListeners
(
$eventName
=
null
)
{
if
(
null
!==
$eventName
)
{
if
(
!
isset
(
$this
->
listeners
[
$eventName
]))
{
return
array
();
}
if
(
!
isset
(
$this
->
sorted
[
$eventName
]))
{
$this
->
sortListeners
(
$eventName
);
}
return
$this
->
sorted
[
$eventName
];
}
foreach
(
$this
->
listeners
as
$eventName
=>
$eventListeners
)
{
if
(
!
isset
(
$this
->
sorted
[
$eventName
]))
{
$this
->
sortListeners
(
$eventName
);
}
}
return
array_filter
(
$this
->
sorted
);
}
/**
* {@inheritdoc}
*/
public
function
getListenerPriority
(
$eventName
,
$listener
)
{
if
(
!
isset
(
$this
->
listeners
[
$eventName
]))
{
return
;
}
foreach
(
$this
->
listeners
[
$eventName
]
as
$priority
=>
$listeners
)
{
if
(
false
!==
in_array
(
$listener
,
$listeners
,
true
))
{
return
$priority
;
}
}
}
/**
* {@inheritdoc}
*/
public
function
hasListeners
(
$eventName
=
null
)
{
return
(
bool
)
$this
->
getListeners
(
$eventName
);
}
/**
* {@inheritdoc}
*/
public
function
addListener
(
$eventName
,
$listener
,
$priority
=
0
)
{
$this
->
listeners
[
$eventName
][
$priority
][]
=
$listener
;
unset
(
$this
->
sorted
[
$eventName
]);
}
/**
* {@inheritdoc}
*/
public
function
removeListener
(
$eventName
,
$listener
)
{
if
(
!
isset
(
$this
->
listeners
[
$eventName
]))
{
return
;
}
foreach
(
$this
->
listeners
[
$eventName
]
as
$priority
=>
$listeners
)
{
if
(
false
!==
(
$key
=
array_search
(
$listener
,
$listeners
,
true
)))
{
unset
(
$this
->
listeners
[
$eventName
][
$priority
][
$key
],
$this
->
sorted
[
$eventName
]);
}
}
}
/**
* {@inheritdoc}
*/
public
function
addSubscriber
(
EventSubscriberInterface
$subscriber
)
{
foreach
(
$subscriber
->
getSubscribedEvents
()
as
$eventName
=>
$params
)
{
if
(
is_string
(
$params
))
{
$this
->
addListener
(
$eventName
,
array
(
$subscriber
,
$params
));
}
elseif
(
is_string
(
$params
[
0
]))
{
$this
->
addListener
(
$eventName
,
array
(
$subscriber
,
$params
[
0
]),
isset
(
$params
[
1
])
?
$params
[
1
]
:
0
);
}
else
{
foreach
(
$params
as
$listener
)
{
$this
->
addListener
(
$eventName
,
array
(
$subscriber
,
$listener
[
0
]),
isset
(
$listener
[
1
])
?
$listener
[
1
]
:
0
);
}
}
}
}
/**
* {@inheritdoc}
*/
public
function
removeSubscriber
(
EventSubscriberInterface
$subscriber
)
{
foreach
(
$subscriber
->
getSubscribedEvents
()
as
$eventName
=>
$params
)
{
if
(
is_array
(
$params
)
&&
is_array
(
$params
[
0
]))
{
foreach
(
$params
as
$listener
)
{
$this
->
removeListener
(
$eventName
,
array
(
$subscriber
,
$listener
[
0
]));
}
}
else
{
$this
->
removeListener
(
$eventName
,
array
(
$subscriber
,
is_string
(
$params
)
?
$params
:
$params
[
0
]));
}
}
}
/**
* Triggers the listeners of an event.
*
* 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
*/
protected
function
doDispatch
(
$listeners
,
$eventName
,
Event
$event
)
{
foreach
(
$listeners
as
$listener
)
{
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
*/
private
function
sortListeners
(
$eventName
)
{
krsort
(
$this
->
listeners
[
$eventName
]);
$this
->
sorted
[
$eventName
]
=
call_user_func_array
(
'array_merge'
,
$this
->
listeners
[
$eventName
]);
}
}
vendor/symfony/event-dispatcher/EventDispatcherInterface.php
deleted
100644 → 0
View file @
a286ee8a
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Symfony\Component\EventDispatcher
;
/**
* The EventDispatcherInterface is the central point of Symfony's event listener system.
* Listeners are registered on the manager and events are dispatched through the
* manager.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
interface
EventDispatcherInterface
{
/**
* Dispatches an event to all registered listeners.
*
* @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
* If not supplied, an empty Event instance is created.
*
* @return Event
*/
public
function
dispatch
(
$eventName
,
Event
$event
=
null
);
/**
* Adds an event listener that listens on the specified events.
*
* @param string $eventName The event to listen on
* @param callable $listener The listener
* @param int $priority The higher this value, the earlier an event
* listener will be triggered in the chain (defaults to 0)
*/
public
function
addListener
(
$eventName
,
$listener
,
$priority
=
0
);
/**
* Adds an event subscriber.
*
* 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
*/
public
function
addSubscriber
(
EventSubscriberInterface
$subscriber
);
/**
* Removes an event listener from the specified events.
*
* @param string $eventName The event to remove a listener from
* @param callable $listener The listener to remove
*/
public
function
removeListener
(
$eventName
,
$listener
);
/**
* Removes an event subscriber.
*
* @param EventSubscriberInterface $subscriber The subscriber
*/
public
function
removeSubscriber
(
EventSubscriberInterface
$subscriber
);
/**
* Gets the listeners of a specific event or all listeners sorted by descending priority.
*
* @param string $eventName The name of the event
*
* @return array The event listeners for the specified event, or all event listeners by event name
*/
public
function
getListeners
(
$eventName
=
null
);
/**
* Gets the listener priority for a specific event.
*
* Returns null if the event or the listener does not exist.
*
* @param string $eventName The name of the event
* @param callable $listener The listener
*
* @return int|null The event listener priority
*/
public
function
getListenerPriority
(
$eventName
,
$listener
);
/**
* Checks whether an event has any registered listeners.
*
* @param string $eventName The name of the event
*
* @return bool true if the specified event has any listeners, false otherwise
*/
public
function
hasListeners
(
$eventName
=
null
);
}
vendor/symfony/event-dispatcher/EventSubscriberInterface.php
deleted
100644 → 0
View file @
a286ee8a
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Symfony\Component\EventDispatcher
;
/**
* An EventSubscriber knows himself what events he is interested in.
* If an EventSubscriber is added to an EventDispatcherInterface, the manager invokes
* {@link getSubscribedEvents} and registers the subscriber as a listener for all
* returned events.
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Bernhard Schussek <bschussek@gmail.com>
*/
interface
EventSubscriberInterface
{
/**
* Returns an array of event names this subscriber wants to listen to.
*
* The array keys are event names and the value can be:
*
* * The method name to call (priority defaults to 0)
* * An array composed of the method name to call and the priority
* * An array of arrays composed of the method names to call and respective
* priorities, or 0 if unset
*
* For instance:
*
* * array('eventName' => 'methodName')
* * array('eventName' => array('methodName', $priority))
* * array('eventName' => array(array('methodName1', $priority), array('methodName2')))
*
* @return array The event names to listen to
*/
public
static
function
getSubscribedEvents
();
}
vendor/symfony/event-dispatcher/GenericEvent.php
deleted
100644 → 0
View file @
a286ee8a
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Symfony\Component\EventDispatcher
;
/**
* Event encapsulation class.
*
* Encapsulates events thus decoupling the observer from the subject they encapsulate.
*
* @author Drak <drak@zikula.org>
*/
class
GenericEvent
extends
Event
implements
\ArrayAccess
,
\IteratorAggregate
{
/**
* Event subject.
*
* @var mixed usually object or callable
*/
protected
$subject
;
/**
* Array of arguments.
*
* @var array
*/
protected
$arguments
;
/**
* 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
*/
public
function
__construct
(
$subject
=
null
,
array
$arguments
=
array
())
{
$this
->
subject
=
$subject
;
$this
->
arguments
=
$arguments
;
}
/**
* Getter for subject property.
*
* @return mixed $subject The observer subject
*/
public
function
getSubject
()
{
return
$this
->
subject
;
}
/**
* Get argument by key.
*
* @param string $key Key
*
* @return mixed Contents of array key
*
* @throws \InvalidArgumentException If key is not found.
*/
public
function
getArgument
(
$key
)
{
if
(
$this
->
hasArgument
(
$key
))
{
return
$this
->
arguments
[
$key
];
}
throw
new
\InvalidArgumentException
(
sprintf
(
'Argument "%s" not found.'
,
$key
));
}
/**
* Add argument to event.
*
* @param string $key Argument name
* @param mixed $value Value
*
* @return $this
*/
public
function
setArgument
(
$key
,
$value
)
{
$this
->
arguments
[
$key
]
=
$value
;
return
$this
;
}
/**
* Getter for all arguments.
*
* @return array
*/
public
function
getArguments
()
{
return
$this
->
arguments
;
}
/**
* Set args property.
*
* @param array $args Arguments
*
* @return $this
*/
public
function
setArguments
(
array
$args
=
array
())
{
$this
->
arguments
=
$args
;
return
$this
;
}
/**
* Has argument.
*
* @param string $key Key of arguments array
*
* @return bool
*/
public
function
hasArgument
(
$key
)
{
return
array_key_exists
(
$key
,
$this
->
arguments
);
}
/**
* ArrayAccess for argument getter.
*
* @param string $key Array key
*
* @return mixed
*
* @throws \InvalidArgumentException If key does not exist in $this->args.
*/
public
function
offsetGet
(
$key
)
{
return
$this
->
getArgument
(
$key
);
}
/**
* ArrayAccess for argument setter.
*
* @param string $key Array key to set
* @param mixed $value Value
*/
public
function
offsetSet
(
$key
,
$value
)
{
$this
->
setArgument
(
$key
,
$value
);
}
/**
* ArrayAccess for unset argument.
*
* @param string $key Array key
*/
public
function
offsetUnset
(
$key
)
{
if
(
$this
->
hasArgument
(
$key
))
{
unset
(
$this
->
arguments
[
$key
]);
}
}
/**
* ArrayAccess has argument.
*
* @param string $key Array key
*
* @return bool
*/
public
function
offsetExists
(
$key
)
{
return
$this
->
hasArgument
(
$key
);
}
/**
* IteratorAggregate for iterating over the object like an array.
*
* @return \ArrayIterator
*/
public
function
getIterator
()
{
return
new
\ArrayIterator
(
$this
->
arguments
);
}
}
vendor/symfony/event-dispatcher/ImmutableEventDispatcher.php
deleted
100644 → 0
View file @
a286ee8a
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Symfony\Component\EventDispatcher
;
/**
* A read-only proxy for an event dispatcher.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class
ImmutableEventDispatcher
implements
EventDispatcherInterface
{
/**
* The proxied dispatcher.
*
* @var EventDispatcherInterface
*/
private
$dispatcher
;
/**
* Creates an unmodifiable proxy for an event dispatcher.
*
* @param EventDispatcherInterface $dispatcher The proxied event dispatcher
*/
public
function
__construct
(
EventDispatcherInterface
$dispatcher
)
{
$this
->
dispatcher
=
$dispatcher
;
}
/**
* {@inheritdoc}
*/
public
function
dispatch
(
$eventName
,
Event
$event
=
null
)
{
return
$this
->
dispatcher
->
dispatch
(
$eventName
,
$event
);
}
/**
* {@inheritdoc}
*/
public
function
addListener
(
$eventName
,
$listener
,
$priority
=
0
)
{
throw
new
\BadMethodCallException
(
'Unmodifiable event dispatchers must not be modified.'
);
}
/**
* {@inheritdoc}
*/
public
function
addSubscriber
(
EventSubscriberInterface
$subscriber
)
{
throw
new
\BadMethodCallException
(
'Unmodifiable event dispatchers must not be modified.'
);
}
/**
* {@inheritdoc}
*/
public
function
removeListener
(
$eventName
,
$listener
)
{
throw
new
\BadMethodCallException
(
'Unmodifiable event dispatchers must not be modified.'
);
}
/**
* {@inheritdoc}
*/
public
function
removeSubscriber
(
EventSubscriberInterface
$subscriber
)
{
throw
new
\BadMethodCallException
(
'Unmodifiable event dispatchers must not be modified.'
);
}
/**
* {@inheritdoc}
*/
public
function
getListeners
(
$eventName
=
null
)
{
return
$this
->
dispatcher
->
getListeners
(
$eventName
);
}
/**
* {@inheritdoc}
*/
public
function
getListenerPriority
(
$eventName
,
$listener
)
{
return
$this
->
dispatcher
->
getListenerPriority
(
$eventName
,
$listener
);
}
/**
* {@inheritdoc}
*/
public
function
hasListeners
(
$eventName
=
null
)
{
return
$this
->
dispatcher
->
hasListeners
(
$eventName
);
}
}
vendor/symfony/event-dispatcher/LICENSE
deleted
100644 → 0
View file @
a286ee8a
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
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
vendor/symfony/event-dispatcher/README.md
deleted
100644 → 0
View file @
a286ee8a
EventDispatcher Component
=========================
The EventDispatcher component provides tools that allow your application
components to communicate with each other by dispatching events and listening to
them.
Resources
---------
*
[
Documentation
](
https://symfony.com/doc/current/components/event_dispatcher/index.html
)
*
[
Contributing
](
https://symfony.com/doc/current/contributing/index.html
)
*
[
Report issues
](
https://github.com/symfony/symfony/issues
)
and
[
send Pull Requests
](
https://github.com/symfony/symfony/pulls
)
in the
[
main Symfony repository
](
https://github.com/symfony/symfony
)
vendor/symfony/event-dispatcher/Tests/AbstractEventDispatcherTest.php
deleted
100644 → 0
View file @
a286ee8a
This diff is collapsed.
Click to expand it.
vendor/symfony/event-dispatcher/Tests/ContainerAwareEventDispatcherTest.php
deleted
100644 → 0
View file @
a286ee8a
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Symfony\Component\EventDispatcher\Tests
;
use
Symfony\Component\DependencyInjection\Container
;
use
Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher
;
use
Symfony\Component\EventDispatcher\Event
;
use
Symfony\Component\EventDispatcher\EventSubscriberInterface
;
class
ContainerAwareEventDispatcherTest
extends
AbstractEventDispatcherTest
{
protected
function
createEventDispatcher
()
{
$container
=
new
Container
();
return
new
ContainerAwareEventDispatcher
(
$container
);
}
public
function
testAddAListenerService
()
{
$event
=
new
Event
();
$service
=
$this
->
getMockBuilder
(
'Symfony\Component\EventDispatcher\Tests\Service'
)
->
getMock
();
$service
->
expects
(
$this
->
once
())
->
method
(
'onEvent'
)
->
with
(
$event
)
;
$container
=
new
Container
();
$container
->
set
(
'service.listener'
,
$service
);
$dispatcher
=
new
ContainerAwareEventDispatcher
(
$container
);
$dispatcher
->
addListenerService
(
'onEvent'
,
array
(
'service.listener'
,
'onEvent'
));
$dispatcher
->
dispatch
(
'onEvent'
,
$event
);
}
public
function
testAddASubscriberService
()
{
$event
=
new
Event
();
$service
=
$this
->
getMockBuilder
(
'Symfony\Component\EventDispatcher\Tests\SubscriberService'
)
->
getMock
();
$service
->
expects
(
$this
->
once
())
->
method
(
'onEvent'
)
->
with
(
$event
)
;
$service
->
expects
(
$this
->
once
())
->
method
(
'onEventWithPriority'
)
->
with
(
$event
)
;
$service
->
expects
(
$this
->
once
())
->
method
(
'onEventNested'
)
->
with
(
$event
)
;
$container
=
new
Container
();
$container
->
set
(
'service.subscriber'
,
$service
);
$dispatcher
=
new
ContainerAwareEventDispatcher
(
$container
);
$dispatcher
->
addSubscriberService
(
'service.subscriber'
,
'Symfony\Component\EventDispatcher\Tests\SubscriberService'
);
$dispatcher
->
dispatch
(
'onEvent'
,
$event
);
$dispatcher
->
dispatch
(
'onEventWithPriority'
,
$event
);
$dispatcher
->
dispatch
(
'onEventNested'
,
$event
);
}
public
function
testPreventDuplicateListenerService
()
{
$event
=
new
Event
();
$service
=
$this
->
getMockBuilder
(
'Symfony\Component\EventDispatcher\Tests\Service'
)
->
getMock
();
$service
->
expects
(
$this
->
once
())
->
method
(
'onEvent'
)
->
with
(
$event
)
;
$container
=
new
Container
();
$container
->
set
(
'service.listener'
,
$service
);
$dispatcher
=
new
ContainerAwareEventDispatcher
(
$container
);
$dispatcher
->
addListenerService
(
'onEvent'
,
array
(
'service.listener'
,
'onEvent'
),
5
);
$dispatcher
->
addListenerService
(
'onEvent'
,
array
(
'service.listener'
,
'onEvent'
),
10
);
$dispatcher
->
dispatch
(
'onEvent'
,
$event
);
}
public
function
testHasListenersOnLazyLoad
()
{
$event
=
new
Event
();
$service
=
$this
->
getMockBuilder
(
'Symfony\Component\EventDispatcher\Tests\Service'
)
->
getMock
();
$container
=
new
Container
();
$container
->
set
(
'service.listener'
,
$service
);
$dispatcher
=
new
ContainerAwareEventDispatcher
(
$container
);
$dispatcher
->
addListenerService
(
'onEvent'
,
array
(
'service.listener'
,
'onEvent'
));
$service
->
expects
(
$this
->
once
())
->
method
(
'onEvent'
)
->
with
(
$event
)
;
$this
->
assertTrue
(
$dispatcher
->
hasListeners
());
if
(
$dispatcher
->
hasListeners
(
'onEvent'
))
{
$dispatcher
->
dispatch
(
'onEvent'
);
}
}
public
function
testGetListenersOnLazyLoad
()
{
$service
=
$this
->
getMockBuilder
(
'Symfony\Component\EventDispatcher\Tests\Service'
)
->
getMock
();
$container
=
new
Container
();
$container
->
set
(
'service.listener'
,
$service
);
$dispatcher
=
new
ContainerAwareEventDispatcher
(
$container
);
$dispatcher
->
addListenerService
(
'onEvent'
,
array
(
'service.listener'
,
'onEvent'
));
$listeners
=
$dispatcher
->
getListeners
();
$this
->
assertTrue
(
isset
(
$listeners
[
'onEvent'
]));
$this
->
assertCount
(
1
,
$dispatcher
->
getListeners
(
'onEvent'
));
}
public
function
testRemoveAfterDispatch
()
{
$service
=
$this
->
getMockBuilder
(
'Symfony\Component\EventDispatcher\Tests\Service'
)
->
getMock
();
$container
=
new
Container
();
$container
->
set
(
'service.listener'
,
$service
);
$dispatcher
=
new
ContainerAwareEventDispatcher
(
$container
);
$dispatcher
->
addListenerService
(
'onEvent'
,
array
(
'service.listener'
,
'onEvent'
));
$dispatcher
->
dispatch
(
'onEvent'
,
new
Event
());
$dispatcher
->
removeListener
(
'onEvent'
,
array
(
$container
->
get
(
'service.listener'
),
'onEvent'
));
$this
->
assertFalse
(
$dispatcher
->
hasListeners
(
'onEvent'
));
}
public
function
testRemoveBeforeDispatch
()
{
$service
=
$this
->
getMockBuilder
(
'Symfony\Component\EventDispatcher\Tests\Service'
)
->
getMock
();
$container
=
new
Container
();
$container
->
set
(
'service.listener'
,
$service
);
$dispatcher
=
new
ContainerAwareEventDispatcher
(
$container
);
$dispatcher
->
addListenerService
(
'onEvent'
,
array
(
'service.listener'
,
'onEvent'
));
$dispatcher
->
removeListener
(
'onEvent'
,
array
(
$container
->
get
(
'service.listener'
),
'onEvent'
));
$this
->
assertFalse
(
$dispatcher
->
hasListeners
(
'onEvent'
));
}
}
class
Service
{
public
function
onEvent
(
Event
$e
)
{
}
}
class
SubscriberService
implements
EventSubscriberInterface
{
public
static
function
getSubscribedEvents
()
{
return
array
(
'onEvent'
=>
'onEvent'
,
'onEventWithPriority'
=>
array
(
'onEventWithPriority'
,
10
),
'onEventNested'
=>
array
(
array
(
'onEventNested'
)),
);
}
public
function
onEvent
(
Event
$e
)
{
}
public
function
onEventWithPriority
(
Event
$e
)
{
}
public
function
onEventNested
(
Event
$e
)
{
}
}
vendor/symfony/event-dispatcher/Tests/Debug/TraceableEventDispatcherTest.php
deleted
100644 → 0
View file @
a286ee8a
This diff is collapsed.
Click to expand it.
vendor/symfony/event-dispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php
deleted
100644 → 0
View file @
a286ee8a
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Symfony\Component\EventDispatcher\Tests\DependencyInjection
;
use
PHPUnit\Framework\TestCase
;
use
Symfony\Component\DependencyInjection\ContainerBuilder
;
use
Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass
;
class
RegisterListenersPassTest
extends
TestCase
{
/**
* Tests that event subscribers not implementing EventSubscriberInterface
* trigger an exception.
*
* @expectedException \InvalidArgumentException
*/
public
function
testEventSubscriberWithoutInterface
()
{
// one service, not implementing any interface
$services
=
array
(
'my_event_subscriber'
=>
array
(
0
=>
array
()),
);
$definition
=
$this
->
getMockBuilder
(
'Symfony\Component\DependencyInjection\Definition'
)
->
getMock
();
$definition
->
expects
(
$this
->
atLeastOnce
())
->
method
(
'isPublic'
)
->
will
(
$this
->
returnValue
(
true
));
$definition
->
expects
(
$this
->
atLeastOnce
())
->
method
(
'getClass'
)
->
will
(
$this
->
returnValue
(
'stdClass'
));
$builder
=
$this
->
getMockBuilder
(
'Symfony\Component\DependencyInjection\ContainerBuilder'
)
->
setMethods
(
array
(
'hasDefinition'
,
'findTaggedServiceIds'
,
'getDefinition'
))
->
getMock
();
$builder
->
expects
(
$this
->
any
())
->
method
(
'hasDefinition'
)
->
will
(
$this
->
returnValue
(
true
));
// We don't test kernel.event_listener here
$builder
->
expects
(
$this
->
atLeastOnce
())
->
method
(
'findTaggedServiceIds'
)
->
will
(
$this
->
onConsecutiveCalls
(
array
(),
$services
));
$builder
->
expects
(
$this
->
atLeastOnce
())
->
method
(
'getDefinition'
)
->
will
(
$this
->
returnValue
(
$definition
));
$registerListenersPass
=
new
RegisterListenersPass
();
$registerListenersPass
->
process
(
$builder
);
}
public
function
testValidEventSubscriber
()
{
$services
=
array
(
'my_event_subscriber'
=>
array
(
0
=>
array
()),
);
$definition
=
$this
->
getMockBuilder
(
'Symfony\Component\DependencyInjection\Definition'
)
->
getMock
();
$definition
->
expects
(
$this
->
atLeastOnce
())
->
method
(
'isPublic'
)
->
will
(
$this
->
returnValue
(
true
));
$definition
->
expects
(
$this
->
atLeastOnce
())
->
method
(
'getClass'
)
->
will
(
$this
->
returnValue
(
'Symfony\Component\EventDispatcher\Tests\DependencyInjection\SubscriberService'
));
$builder
=
$this
->
getMockBuilder
(
'Symfony\Component\DependencyInjection\ContainerBuilder'
)
->
setMethods
(
array
(
'hasDefinition'
,
'findTaggedServiceIds'
,
'getDefinition'
,
'findDefinition'
))
->
getMock
();
$builder
->
expects
(
$this
->
any
())
->
method
(
'hasDefinition'
)
->
will
(
$this
->
returnValue
(
true
));
// We don't test kernel.event_listener here
$builder
->
expects
(
$this
->
atLeastOnce
())
->
method
(
'findTaggedServiceIds'
)
->
will
(
$this
->
onConsecutiveCalls
(
array
(),
$services
));
$builder
->
expects
(
$this
->
atLeastOnce
())
->
method
(
'getDefinition'
)
->
will
(
$this
->
returnValue
(
$definition
));
$builder
->
expects
(
$this
->
atLeastOnce
())
->
method
(
'findDefinition'
)
->
will
(
$this
->
returnValue
(
$definition
));
$registerListenersPass
=
new
RegisterListenersPass
();
$registerListenersPass
->
process
(
$builder
);
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The service "foo" must be public as event listeners are lazy-loaded.
*/
public
function
testPrivateEventListener
()
{
$container
=
new
ContainerBuilder
();
$container
->
register
(
'foo'
,
'stdClass'
)
->
setPublic
(
false
)
->
addTag
(
'kernel.event_listener'
,
array
());
$container
->
register
(
'event_dispatcher'
,
'stdClass'
);
$registerListenersPass
=
new
RegisterListenersPass
();
$registerListenersPass
->
process
(
$container
);
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The service "foo" must be public as event subscribers are lazy-loaded.
*/
public
function
testPrivateEventSubscriber
()
{
$container
=
new
ContainerBuilder
();
$container
->
register
(
'foo'
,
'stdClass'
)
->
setPublic
(
false
)
->
addTag
(
'kernel.event_subscriber'
,
array
());
$container
->
register
(
'event_dispatcher'
,
'stdClass'
);
$registerListenersPass
=
new
RegisterListenersPass
();
$registerListenersPass
->
process
(
$container
);
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The service "foo" must not be abstract as event listeners are lazy-loaded.
*/
public
function
testAbstractEventListener
()
{
$container
=
new
ContainerBuilder
();
$container
->
register
(
'foo'
,
'stdClass'
)
->
setAbstract
(
true
)
->
addTag
(
'kernel.event_listener'
,
array
());
$container
->
register
(
'event_dispatcher'
,
'stdClass'
);
$registerListenersPass
=
new
RegisterListenersPass
();
$registerListenersPass
->
process
(
$container
);
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The service "foo" must not be abstract as event subscribers are lazy-loaded.
*/
public
function
testAbstractEventSubscriber
()
{
$container
=
new
ContainerBuilder
();
$container
->
register
(
'foo'
,
'stdClass'
)
->
setAbstract
(
true
)
->
addTag
(
'kernel.event_subscriber'
,
array
());
$container
->
register
(
'event_dispatcher'
,
'stdClass'
);
$registerListenersPass
=
new
RegisterListenersPass
();
$registerListenersPass
->
process
(
$container
);
}
public
function
testEventSubscriberResolvableClassName
()
{
$container
=
new
ContainerBuilder
();
$container
->
setParameter
(
'subscriber.class'
,
'Symfony\Component\EventDispatcher\Tests\DependencyInjection\SubscriberService'
);
$container
->
register
(
'foo'
,
'%subscriber.class%'
)
->
addTag
(
'kernel.event_subscriber'
,
array
());
$container
->
register
(
'event_dispatcher'
,
'stdClass'
);
$registerListenersPass
=
new
RegisterListenersPass
();
$registerListenersPass
->
process
(
$container
);
$definition
=
$container
->
getDefinition
(
'event_dispatcher'
);
$expected_calls
=
array
(
array
(
'addSubscriberService'
,
array
(
'foo'
,
'Symfony\Component\EventDispatcher\Tests\DependencyInjection\SubscriberService'
,
),
),
);
$this
->
assertSame
(
$expected_calls
,
$definition
->
getMethodCalls
());
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage You have requested a non-existent parameter "subscriber.class"
*/
public
function
testEventSubscriberUnresolvableClassName
()
{
$container
=
new
ContainerBuilder
();
$container
->
register
(
'foo'
,
'%subscriber.class%'
)
->
addTag
(
'kernel.event_subscriber'
,
array
());
$container
->
register
(
'event_dispatcher'
,
'stdClass'
);
$registerListenersPass
=
new
RegisterListenersPass
();
$registerListenersPass
->
process
(
$container
);
}
}
class
SubscriberService
implements
\Symfony\Component\EventDispatcher\EventSubscriberInterface
{
public
static
function
getSubscribedEvents
()
{
}
}
vendor/symfony/event-dispatcher/Tests/EventDispatcherTest.php
deleted
100644 → 0
View file @
a286ee8a
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Symfony\Component\EventDispatcher\Tests
;
use
Symfony\Component\EventDispatcher\EventDispatcher
;
class
EventDispatcherTest
extends
AbstractEventDispatcherTest
{
protected
function
createEventDispatcher
()
{
return
new
EventDispatcher
();
}
}
vendor/symfony/event-dispatcher/Tests/EventTest.php
deleted
100644 → 0
View file @
a286ee8a
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Symfony\Component\EventDispatcher\Tests
;
use
PHPUnit\Framework\TestCase
;
use
Symfony\Component\EventDispatcher\Event
;
/**
* Test class for Event.
*/
class
EventTest
extends
TestCase
{
/**
* @var \Symfony\Component\EventDispatcher\Event
*/
protected
$event
;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected
function
setUp
()
{
$this
->
event
=
new
Event
();
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected
function
tearDown
()
{
$this
->
event
=
null
;
}
public
function
testIsPropagationStopped
()
{
$this
->
assertFalse
(
$this
->
event
->
isPropagationStopped
());
}
public
function
testStopPropagationAndIsPropagationStopped
()
{
$this
->
event
->
stopPropagation
();
$this
->
assertTrue
(
$this
->
event
->
isPropagationStopped
());
}
}
vendor/symfony/event-dispatcher/Tests/GenericEventTest.php
deleted
100644 → 0
View file @
a286ee8a
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Symfony\Component\EventDispatcher\Tests
;
use
PHPUnit\Framework\TestCase
;
use
Symfony\Component\EventDispatcher\GenericEvent
;
/**
* Test class for Event.
*/
class
GenericEventTest
extends
TestCase
{
/**
* @var GenericEvent
*/
private
$event
;
private
$subject
;
/**
* Prepares the environment before running a test.
*/
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
subject
=
new
\stdClass
();
$this
->
event
=
new
GenericEvent
(
$this
->
subject
,
array
(
'name'
=>
'Event'
));
}
/**
* Cleans up the environment after running a test.
*/
protected
function
tearDown
()
{
$this
->
subject
=
null
;
$this
->
event
=
null
;
parent
::
tearDown
();
}
public
function
testConstruct
()
{
$this
->
assertEquals
(
$this
->
event
,
new
GenericEvent
(
$this
->
subject
,
array
(
'name'
=>
'Event'
)));
}
/**
* Tests Event->getArgs().
*/
public
function
testGetArguments
()
{
// test getting all
$this
->
assertSame
(
array
(
'name'
=>
'Event'
),
$this
->
event
->
getArguments
());
}
public
function
testSetArguments
()
{
$result
=
$this
->
event
->
setArguments
(
array
(
'foo'
=>
'bar'
));
$this
->
assertAttributeSame
(
array
(
'foo'
=>
'bar'
),
'arguments'
,
$this
->
event
);
$this
->
assertSame
(
$this
->
event
,
$result
);
}
public
function
testSetArgument
()
{
$result
=
$this
->
event
->
setArgument
(
'foo2'
,
'bar2'
);
$this
->
assertAttributeSame
(
array
(
'name'
=>
'Event'
,
'foo2'
=>
'bar2'
),
'arguments'
,
$this
->
event
);
$this
->
assertEquals
(
$this
->
event
,
$result
);
}
public
function
testGetArgument
()
{
// test getting key
$this
->
assertEquals
(
'Event'
,
$this
->
event
->
getArgument
(
'name'
));
}
/**
* @expectedException \InvalidArgumentException
*/
public
function
testGetArgException
()
{
$this
->
event
->
getArgument
(
'nameNotExist'
);
}
public
function
testOffsetGet
()
{
// test getting key
$this
->
assertEquals
(
'Event'
,
$this
->
event
[
'name'
]);
// test getting invalid arg
$this
->
{
method_exists
(
$this
,
$_
=
'expectException'
)
?
$_
:
'setExpectedException'
}(
'InvalidArgumentException'
);
$this
->
assertFalse
(
$this
->
event
[
'nameNotExist'
]);
}
public
function
testOffsetSet
()
{
$this
->
event
[
'foo2'
]
=
'bar2'
;
$this
->
assertAttributeSame
(
array
(
'name'
=>
'Event'
,
'foo2'
=>
'bar2'
),
'arguments'
,
$this
->
event
);
}
public
function
testOffsetUnset
()
{
unset
(
$this
->
event
[
'name'
]);
$this
->
assertAttributeSame
(
array
(),
'arguments'
,
$this
->
event
);
}
public
function
testOffsetIsset
()
{
$this
->
assertTrue
(
isset
(
$this
->
event
[
'name'
]));
$this
->
assertFalse
(
isset
(
$this
->
event
[
'nameNotExist'
]));
}
public
function
testHasArgument
()
{
$this
->
assertTrue
(
$this
->
event
->
hasArgument
(
'name'
));
$this
->
assertFalse
(
$this
->
event
->
hasArgument
(
'nameNotExist'
));
}
public
function
testGetSubject
()
{
$this
->
assertSame
(
$this
->
subject
,
$this
->
event
->
getSubject
());
}
public
function
testHasIterator
()
{
$data
=
array
();
foreach
(
$this
->
event
as
$key
=>
$value
)
{
$data
[
$key
]
=
$value
;
}
$this
->
assertEquals
(
array
(
'name'
=>
'Event'
),
$data
);
}
}
vendor/symfony/event-dispatcher/Tests/ImmutableEventDispatcherTest.php
deleted
100644 → 0
View file @
a286ee8a
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Symfony\Component\EventDispatcher\Tests
;
use
PHPUnit\Framework\TestCase
;
use
Symfony\Component\EventDispatcher\Event
;
use
Symfony\Component\EventDispatcher\ImmutableEventDispatcher
;
/**
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class
ImmutableEventDispatcherTest
extends
TestCase
{
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private
$innerDispatcher
;
/**
* @var ImmutableEventDispatcher
*/
private
$dispatcher
;
protected
function
setUp
()
{
$this
->
innerDispatcher
=
$this
->
getMockBuilder
(
'Symfony\Component\EventDispatcher\EventDispatcherInterface'
)
->
getMock
();
$this
->
dispatcher
=
new
ImmutableEventDispatcher
(
$this
->
innerDispatcher
);
}
public
function
testDispatchDelegates
()
{
$event
=
new
Event
();
$this
->
innerDispatcher
->
expects
(
$this
->
once
())
->
method
(
'dispatch'
)
->
with
(
'event'
,
$event
)
->
will
(
$this
->
returnValue
(
'result'
));
$this
->
assertSame
(
'result'
,
$this
->
dispatcher
->
dispatch
(
'event'
,
$event
));
}
public
function
testGetListenersDelegates
()
{
$this
->
innerDispatcher
->
expects
(
$this
->
once
())
->
method
(
'getListeners'
)
->
with
(
'event'
)
->
will
(
$this
->
returnValue
(
'result'
));
$this
->
assertSame
(
'result'
,
$this
->
dispatcher
->
getListeners
(
'event'
));
}
public
function
testHasListenersDelegates
()
{
$this
->
innerDispatcher
->
expects
(
$this
->
once
())
->
method
(
'hasListeners'
)
->
with
(
'event'
)
->
will
(
$this
->
returnValue
(
'result'
));
$this
->
assertSame
(
'result'
,
$this
->
dispatcher
->
hasListeners
(
'event'
));
}
/**
* @expectedException \BadMethodCallException
*/
public
function
testAddListenerDisallowed
()
{
$this
->
dispatcher
->
addListener
(
'event'
,
function
()
{
return
'foo'
;
});
}
/**
* @expectedException \BadMethodCallException
*/
public
function
testAddSubscriberDisallowed
()
{
$subscriber
=
$this
->
getMockBuilder
(
'Symfony\Component\EventDispatcher\EventSubscriberInterface'
)
->
getMock
();
$this
->
dispatcher
->
addSubscriber
(
$subscriber
);
}
/**
* @expectedException \BadMethodCallException
*/
public
function
testRemoveListenerDisallowed
()
{
$this
->
dispatcher
->
removeListener
(
'event'
,
function
()
{
return
'foo'
;
});
}
/**
* @expectedException \BadMethodCallException
*/
public
function
testRemoveSubscriberDisallowed
()
{
$subscriber
=
$this
->
getMockBuilder
(
'Symfony\Component\EventDispatcher\EventSubscriberInterface'
)
->
getMock
();
$this
->
dispatcher
->
removeSubscriber
(
$subscriber
);
}
}
vendor/symfony/event-dispatcher/composer.json
deleted
100644 → 0
View file @
a286ee8a
{
"name"
:
"symfony/event-dispatcher"
,
"type"
:
"library"
,
"description"
:
"Symfony EventDispatcher Component"
,
"keywords"
:
[],
"homepage"
:
"https://symfony.com"
,
"license"
:
"MIT"
,
"authors"
:
[
{
"name"
:
"Fabien Potencier"
,
"email"
:
"fabien@symfony.com"
},
{
"name"
:
"Symfony Community"
,
"homepage"
:
"https://symfony.com/contributors"
}
],
"require"
:
{
"php"
:
">=5.5.9"
},
"require-dev"
:
{
"symfony/dependency-injection"
:
"~2.8|~3.0"
,
"symfony/expression-language"
:
"~2.8|~3.0"
,
"symfony/config"
:
"~2.8|~3.0"
,
"symfony/stopwatch"
:
"~2.8|~3.0"
,
"psr/log"
:
"~1.0"
},
"suggest"
:
{
"symfony/dependency-injection"
:
""
,
"symfony/http-kernel"
:
""
},
"autoload"
:
{
"psr-4"
:
{
"Symfony
\\
Component
\\
EventDispatcher
\\
"
:
""
},
"exclude-from-classmap"
:
[
"/Tests/"
]
},
"minimum-stability"
:
"dev"
,
"extra"
:
{
"branch-alias"
:
{
"dev-master"
:
"3.2-dev"
}
}
}
vendor/symfony/event-dispatcher/phpunit.xml.dist
deleted
100644 → 0
View file @
a286ee8a
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation=
"http://schema.phpunit.de/4.1/phpunit.xsd"
backupGlobals=
"false"
colors=
"true"
bootstrap=
"vendor/autoload.php"
failOnRisky=
"true"
failOnWarning=
"true"
>
<php>
<ini
name=
"error_reporting"
value=
"-1"
/>
</php>
<testsuites>
<testsuite
name=
"Symfony EventDispatcher Component Test Suite"
>
<directory>
./Tests/
</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>
./
</directory>
<exclude>
<directory>
./Resources
</directory>
<directory>
./Tests
</directory>
<directory>
./vendor
</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment