Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
solarium
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
solarium
Commits
5fabd8bb
Commit
5fabd8bb
authored
Oct 08, 2014
by
Bart Feenstra
Committed by
Bas de Nooijer
Nov 10, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow the event dispatcher to be injected.
parent
df971be8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
9 deletions
+41
-9
library/Solarium/Core/Client/Client.php
library/Solarium/Core/Client/Client.php
+27
-9
tests/Solarium/Tests/Core/Client/ClientTest.php
tests/Solarium/Tests/Core/Client/ClientTest.php
+14
-0
No files found.
library/Solarium/Core/Client/Client.php
View file @
5fabd8bb
...
...
@@ -59,6 +59,7 @@ use Solarium\Core\Event\PreExecute as PreExecuteEvent;
use
Solarium\Core\Event\PostExecute
as
PostExecuteEvent
;
use
Solarium\Core\Event\PreExecuteRequest
as
PreExecuteRequestEvent
;
use
Solarium\Core\Event\PostExecuteRequest
as
PostExecuteRequestEvent
;
use
Symfony\Component\EventDispatcher\EventDispatcherInterface
;
/**
* Main interface for interaction with Solr
...
...
@@ -219,7 +220,6 @@ class Client extends Configurable
*/
protected
function
init
()
{
$this
->
eventDispatcher
=
new
EventDispatcher
();
foreach
(
$this
->
options
as
$name
=>
$value
)
{
switch
(
$name
)
{
case
'endpoint'
:
...
...
@@ -562,15 +562,33 @@ class Client extends Configurable
}
/**
* Get the EventDispatcherInstance
* Gets the event dispatcher.
*
* @return EventDispatcher
* @return EventDispatcherInterface
*/
public
function
getEventDispatcher
()
{
if
(
!
$this
->
eventDispatcher
)
{
$this
->
eventDispatcher
=
new
EventDispatcher
();
}
return
$this
->
eventDispatcher
;
}
/**
* Sets the event dispatcher.
*
* @param EventDispatcherInterface $eventDispatcher
*
* @return $this
*/
public
function
setEventDispatcher
(
EventDispatcherInterface
$eventDispatcher
)
{
$this
->
eventDispatcher
=
$eventDispatcher
;
return
$this
;
}
/**
* Register a plugin
*
...
...
tests/Solarium/Tests/Core/Client/ClientTest.php
View file @
5fabd8bb
...
...
@@ -57,6 +57,9 @@ use Solarium\Core\Event\PostExecute as PostExecuteEvent;
use
Solarium\Core\Event\PreExecuteRequest
as
PreExecuteRequestEvent
;
use
Solarium\Core\Event\PostExecuteRequest
as
PostExecuteRequestEvent
;
/**
* @coversDefaultClass \Solarium\Core\Client\Client
*/
class
ClientTest
extends
\PHPUnit_Framework_TestCase
{
/**
...
...
@@ -112,6 +115,17 @@ class ClientTest extends \PHPUnit_Framework_TestCase
}
/**
* @covers ::getEventDispatcher
* @covers ::setEventDispatcher
*/
public
function
testGetEventDispatcher
()
{
$this
->
assertInstanceOf
(
'\Symfony\Component\EventDispatcher\EventDispatcherInterface'
,
$this
->
client
->
getEventDispatcher
());
$event_dispatcher
=
$this
->
getMock
(
'\Symfony\Component\EventDispatcher\EventDispatcherInterface'
);
$this
->
client
->
setEventDispatcher
(
$event_dispatcher
);
$this
->
assertSame
(
$event_dispatcher
,
$this
->
client
->
getEventDispatcher
());
}
public
function
testConfigModeWithoutKeys
()
{
$options
=
array
(
...
...
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