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
8726216f
Commit
8726216f
authored
May 15, 2011
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- plugin support object instances
- unittest improvements
parent
995bcabb
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
4 deletions
+28
-4
library/Solarium/Client.php
library/Solarium/Client.php
+3
-1
library/Solarium/Plugin/Abstract.php
library/Solarium/Plugin/Abstract.php
+18
-2
tests/Solarium/Client/RequestBuilder/SelectTest.php
tests/Solarium/Client/RequestBuilder/SelectTest.php
+5
-0
tests/Solarium/Plugin/AbstractTest.php
tests/Solarium/Plugin/AbstractTest.php
+2
-1
No files found.
library/Solarium/Client.php
View file @
8726216f
...
@@ -232,13 +232,15 @@ class Solarium_Client extends Solarium_Configurable
...
@@ -232,13 +232,15 @@ class Solarium_Client extends Solarium_Configurable
public
function
registerPlugin
(
$key
,
$plugin
,
$options
=
array
())
public
function
registerPlugin
(
$key
,
$plugin
,
$options
=
array
())
{
{
if
(
is_string
(
$plugin
))
{
if
(
is_string
(
$plugin
))
{
$plugin
=
new
$plugin
(
$this
,
$options
)
;
$plugin
=
new
$plugin
;
}
}
if
(
!
(
$plugin
instanceof
Solarium_Plugin_Abstract
))
{
if
(
!
(
$plugin
instanceof
Solarium_Plugin_Abstract
))
{
throw
new
Solarium_Exception
(
'All plugins must extend Solarium_Plugin_Abstract'
);
throw
new
Solarium_Exception
(
'All plugins must extend Solarium_Plugin_Abstract'
);
}
}
$plugin
->
init
(
$this
,
$options
);
$this
->
_plugins
[
$key
]
=
$plugin
;
$this
->
_plugins
[
$key
]
=
$plugin
;
return
$this
;
return
$this
;
...
...
library/Solarium/Plugin/Abstract.php
View file @
8726216f
...
@@ -51,15 +51,31 @@ abstract class Solarium_Plugin_Abstract extends Solarium_Configurable
...
@@ -51,15 +51,31 @@ abstract class Solarium_Plugin_Abstract extends Solarium_Configurable
protected
$_client
;
protected
$_client
;
/**
/**
* Constructor
* Initialize
*
* This method is called when the plugin is registered to a client instance
*
*
* @param Solarium_Client $client
* @param Solarium_Client $client
* @param array $options
* @param array $options
*/
*/
public
function
__construc
t
(
$client
,
$options
)
public
function
ini
t
(
$client
,
$options
)
{
{
$this
->
_client
=
$client
;
$this
->
_client
=
$client
;
parent
::
__construct
(
$options
);
parent
::
__construct
(
$options
);
$this
->
_init
();
}
/**
* Secondary init function
*
* This is an extension point for plugin implemenations
*
* @return void
*/
public
function
_init
()
{
}
}
/**
/**
...
...
tests/Solarium/Client/RequestBuilder/SelectTest.php
View file @
8726216f
...
@@ -108,4 +108,9 @@ class Solarium_Client_RequestBuilder_SelectTest extends PHPUnit_Framework_TestCa
...
@@ -108,4 +108,9 @@ class Solarium_Client_RequestBuilder_SelectTest extends PHPUnit_Framework_TestCa
);
);
}
}
public
function
testWithComponents
()
{
//1 component met en 1 zonder builder registratie
}
}
}
\ No newline at end of file
tests/Solarium/Plugin/AbstractTest.php
View file @
8726216f
...
@@ -37,7 +37,8 @@ class Solarium_Plugin_AbstractTest extends PHPUnit_Framework_TestCase
...
@@ -37,7 +37,8 @@ class Solarium_Plugin_AbstractTest extends PHPUnit_Framework_TestCase
{
{
$this
->
_client
=
'dummy'
;
$this
->
_client
=
'dummy'
;
$this
->
_options
=
array
(
'option1'
=>
1
);
$this
->
_options
=
array
(
'option1'
=>
1
);
$this
->
_plugin
=
new
MyPlugin
(
$this
->
_client
,
$this
->
_options
);
$this
->
_plugin
=
new
MyPlugin
();
$this
->
_plugin
->
init
(
$this
->
_client
,
$this
->
_options
);
}
}
public
function
testConstructor
()
public
function
testConstructor
()
...
...
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