Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
b88ea073
Commit
b88ea073
authored
Sep 06, 2012
by
tim.plunkett
Browse files
Issue
#1776494
by tim.plunkett: Fix failures exposed by plugin instantiation test.
parent
c9139f27
Changes
25
Hide whitespace changes
Inline
Side-by-side
lib/Drupal/views/Plugin/Type/ViewsPluginManager.php
View file @
b88ea073
...
...
@@ -11,7 +11,6 @@
use
Drupal\Component\Plugin\Factory\DefaultFactory
;
use
Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery
;
use
Drupal\Core\Plugin\Discovery\CacheDecorator
;
use
Drupal\Component\Plugin\Exception\PluginException
;
class
ViewsPluginManager
extends
PluginManagerBase
{
...
...
@@ -36,7 +35,7 @@ public function __construct($type) {
$this
->
type
=
$type
;
$this
->
discovery
=
new
CacheDecorator
(
new
AnnotatedClassDiscovery
(
'views'
,
$this
->
type
),
'views:'
.
$this
->
type
,
'views'
);
$this
->
factory
=
new
DefaultFactory
(
$this
->
discovery
);
$this
->
factory
=
new
DefaultFactory
(
$this
);
$this
->
coreModules
=
views_core_modules
();
}
...
...
@@ -71,28 +70,8 @@ public function processDefinition(&$definition, $plugin_id) {
'theme path'
=>
$theme_path
,
'theme file'
=>
$theme_file
,
'parent'
=>
'parent'
,
'plugin_type'
=>
$this
->
type
,
);
}
/**
* Creates a plugin from an ID.
*
* @param string $plugin_id
* The plugin ID.
* @param array|false $definition
* Either the definition array, or FALSE if it needs to be loaded.
*
* @return Drupal\views\Plugin\views\PluginBase
* The plugin instance.
*/
public
function
createPluginFromId
(
$plugin_id
,
$definition
=
FALSE
)
{
if
(
!
$definition
)
{
$definition
=
$this
->
getDefinition
(
$plugin_id
);
}
if
(
!
empty
(
$definition
))
{
$instance
=
$this
->
createInstance
(
$plugin_id
,
array
(
'type'
=>
$this
->
type
,
'definition'
=>
$definition
));
return
$instance
;
}
}
}
lib/Drupal/views/Plugin/views/HandlerBase.php
View file @
b88ea073
...
...
@@ -7,6 +7,7 @@
namespace
Drupal\views\Plugin\views
;
use
Drupal\Component\Plugin\Discovery\DiscoveryInterface
;
use
Drupal\views\Plugin\views\PluginBase
;
use
Drupal\views\View
;
...
...
@@ -72,8 +73,8 @@ abstract class HandlerBase extends PluginBase {
/**
* Constructs a Handler object.
*/
public
function
__construct
(
array
$configuration
,
$plugin_id
)
{
parent
::
__construct
(
$configuration
,
$plugin_id
);
public
function
__construct
(
array
$configuration
,
$plugin_id
,
DiscoveryInterface
$discovery
)
{
parent
::
__construct
(
$configuration
,
$plugin_id
,
$discovery
);
$this
->
is_handler
=
TRUE
;
}
...
...
@@ -87,6 +88,7 @@ public function __construct(array $configuration, $plugin_id) {
* based upon the type of handler.
*/
public
function
init
(
&
$view
,
&
$options
)
{
$this
->
setOptionDefaults
(
$this
->
options
,
$this
->
defineOptions
());
$this
->
view
=
&
$view
;
$display_id
=
$this
->
view
->
current_display
;
// Check to see if this handler type is defaulted. Note that
...
...
lib/Drupal/views/Plugin/views/PluginBase.php
View file @
b88ea073
...
...
@@ -7,6 +7,7 @@
namespace
Drupal\views\Plugin\views
;
use
Drupal\Component\Plugin\Discovery\DiscoveryInterface
;
use
Drupal\Component\Plugin\PluginBase
as
ComponentPluginBase
;
abstract
class
PluginBase
extends
ComponentPluginBase
{
...
...
@@ -56,14 +57,19 @@ abstract class PluginBase extends ComponentPluginBase {
/**
* Constructs a Plugin object.
*/
public
function
__construct
(
array
$configuration
,
$plugin_id
)
{
$this
->
configuration
=
$configuration
;
$this
->
plugin_id
=
$plugin_id
;
$this
->
plugin_type
=
$configuration
[
'type'
];
$this
->
definition
=
$configuration
[
'definition'
];
public
function
__construct
(
array
$configuration
,
$plugin_id
,
DiscoveryInterface
$discovery
)
{
parent
::
__construct
(
$configuration
,
$plugin_id
,
$discovery
);
$this
->
definition
=
$this
->
discovery
->
getDefinition
(
$plugin_id
)
+
$configuration
;
// @todo Change calls to $this->plugin_type to use the definition directly.
$this
->
plugin_type
=
$this
->
definition
[
'plugin_type'
];
// @todo Change calls to $this->real_field to use the definition directly.
if
(
isset
(
$this
->
definition
[
'field'
]))
{
$this
->
real_field
=
$this
->
definition
[
'field'
];
}
$this
->
construct
();
}
...
...
@@ -97,7 +103,6 @@ protected function defineOptions() { return array(); }
* easily construct them with variable arguments.
*/
public
function
construct
()
{
$this
->
setOptionDefaults
(
$this
->
options
,
$this
->
defineOptions
());
}
protected
function
setOptionDefaults
(
&
$storage
,
$options
,
$level
=
0
)
{
...
...
lib/Drupal/views/Plugin/views/access/AccessPluginBase.php
View file @
b88ea073
...
...
@@ -31,6 +31,7 @@ abstract class AccessPluginBase extends PluginBase {
* The display handler.
*/
public
function
init
(
&
$view
,
&
$display
)
{
$this
->
setOptionDefaults
(
$this
->
options
,
$this
->
defineOptions
());
$this
->
view
=
&
$view
;
$this
->
display
=
&
$display
;
...
...
lib/Drupal/views/Plugin/views/area/AreaPluginBase.php
View file @
b88ea073
...
...
@@ -31,6 +31,7 @@ abstract class AreaPluginBase extends HandlerBase {
* is empty.
*/
public
function
init
(
&
$view
,
&
$options
)
{
$this
->
setOptionDefaults
(
$this
->
options
,
$this
->
defineOptions
());
parent
::
init
(
$view
,
$options
);
if
(
$this
->
handler_type
==
'empty'
)
{
$this
->
options
[
'empty'
]
=
TRUE
;
...
...
lib/Drupal/views/Plugin/views/argument_default/ArgumentDefaultPluginBase.php
View file @
b88ea073
...
...
@@ -34,6 +34,7 @@ function get_argument() { }
* it is linked to.
*/
public
function
init
(
&
$view
,
&
$argument
,
$options
)
{
$this
->
setOptionDefaults
(
$this
->
options
,
$this
->
defineOptions
());
$this
->
view
=
&
$view
;
$this
->
argument
=
&
$argument
;
...
...
lib/Drupal/views/Plugin/views/argument_validator/ArgumentValidatorPluginBase.php
View file @
b88ea073
...
...
@@ -27,6 +27,7 @@ abstract class ArgumentValidatorPluginBase extends PluginBase {
* it is linked to.
*/
public
function
init
(
&
$view
,
&
$argument
,
$options
)
{
$this
->
setOptionDefaults
(
$this
->
options
,
$this
->
defineOptions
());
$this
->
view
=
&
$view
;
$this
->
argument
=
&
$argument
;
...
...
lib/Drupal/views/Plugin/views/cache/CachePluginBase.php
View file @
b88ea073
...
...
@@ -60,6 +60,7 @@ abstract class CachePluginBase extends PluginBase {
* The display handler.
*/
public
function
init
(
&
$view
,
&
$display
)
{
$this
->
setOptionDefaults
(
$this
->
options
,
$this
->
defineOptions
());
$this
->
view
=
&
$view
;
$this
->
display
=
&
$display
;
...
...
lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
View file @
b88ea073
...
...
@@ -86,6 +86,7 @@ abstract class DisplayPluginBase extends PluginBase {
protected
$usesAttachments
=
FALSE
;
public
function
init
(
&
$view
,
&
$display
,
$options
=
NULL
)
{
$this
->
setOptionDefaults
(
$this
->
options
,
$this
->
defineOptions
());
$this
->
view
=
&
$view
;
$this
->
display
=
&
$display
;
...
...
lib/Drupal/views/Plugin/views/display_extender/DisplayExtenderPluginBase.php
View file @
b88ea073
...
...
@@ -18,6 +18,7 @@
abstract
class
DisplayExtenderPluginBase
extends
PluginBase
{
public
function
init
(
&
$view
,
&
$display
)
{
$this
->
setOptionDefaults
(
$this
->
options
,
$this
->
defineOptions
());
$this
->
view
=
$view
;
$this
->
display
=
$display
;
}
...
...
lib/Drupal/views/Plugin/views/exposed_form/ExposedFormPluginBase.php
View file @
b88ea073
...
...
@@ -38,6 +38,7 @@ abstract class ExposedFormPluginBase extends PluginBase {
* The display handler.
*/
public
function
init
(
&
$view
,
&
$display
,
$options
=
array
())
{
$this
->
setOptionDefaults
(
$this
->
options
,
$this
->
defineOptions
());
$this
->
view
=
&
$view
;
$this
->
display
=
&
$display
;
...
...
lib/Drupal/views/Plugin/views/field/Markup.php
View file @
b88ea073
...
...
@@ -26,11 +26,8 @@
*/
class
Markup
extends
FieldPluginBase
{
/**
* Constructor; calls to base object constructor.
*/
public
function
construct
()
{
parent
::
construct
();
public
function
init
(
&
$view
,
&
$options
)
{
parent
::
init
(
$view
,
$options
);
$this
->
format
=
$this
->
definition
[
'format'
];
...
...
lib/Drupal/views/Plugin/views/filter/Broken.php
View file @
b88ea073
...
...
@@ -24,6 +24,7 @@ public function adminLabel($short = FALSE) {
return
t
(
'Broken/missing handler'
);
}
public
function
init
(
&
$view
,
&
$options
)
{
}
public
function
defineOptions
()
{
return
array
();
}
public
function
ensureMyTable
()
{
/* No table to ensure! */
}
public
function
query
(
$group_by
=
FALSE
)
{
/* No query to run */
}
...
...
lib/Drupal/views/Plugin/views/localization/LocalizationPluginBase.php
View file @
b88ea073
...
...
@@ -34,6 +34,7 @@ abstract class LocalizationPluginBase extends PluginBase {
* The view object.
*/
public
function
init
(
&
$view
)
{
$this
->
setOptionDefaults
(
$this
->
options
,
$this
->
defineOptions
());
$this
->
view
=
&
$view
;
}
...
...
lib/Drupal/views/Plugin/views/pager/PagerPluginBase.php
View file @
b88ea073
...
...
@@ -40,6 +40,7 @@ abstract class PagerPluginBase extends PluginBase {
* The display handler.
*/
public
function
init
(
&
$view
,
&
$display
,
$options
=
array
())
{
$this
->
setOptionDefaults
(
$this
->
options
,
$this
->
defineOptions
());
$this
->
view
=
&
$view
;
$this
->
display
=
&
$display
;
...
...
lib/Drupal/views/Plugin/views/query/QueryPluginBase.php
View file @
b88ea073
...
...
@@ -25,6 +25,7 @@ abstract class QueryPluginBase extends PluginBase implements QueryInterface {
* Constructor; Create the basic query object and fill with default values.
*/
public
function
init
(
$base_table
,
$base_field
,
$options
)
{
$this
->
setOptionDefaults
(
$this
->
options
,
$this
->
defineOptions
());
$this
->
base_table
=
$base_table
;
$this
->
base_field
=
$base_field
;
$this
->
unpackOptions
(
$this
->
options
,
$options
);
...
...
lib/Drupal/views/Plugin/views/relationship/RelationshipPluginBase.php
View file @
b88ea073
...
...
@@ -48,6 +48,7 @@ abstract class RelationshipPluginBase extends HandlerBase {
* the table they operate on.
*/
public
function
init
(
&
$view
,
&
$options
)
{
$this
->
setOptionDefaults
(
$this
->
options
,
$this
->
defineOptions
());
parent
::
init
(
$view
,
$options
);
if
(
isset
(
$this
->
definition
[
'relationship table'
]))
{
$this
->
table
=
$this
->
definition
[
'relationship table'
];
...
...
lib/Drupal/views/Plugin/views/row/RowPluginBase.php
View file @
b88ea073
...
...
@@ -42,6 +42,7 @@ abstract class RowPluginBase extends PluginBase {
* Initialize the row plugin.
*/
public
function
init
(
&
$view
,
&
$display
,
$options
=
NULL
)
{
$this
->
setOptionDefaults
(
$this
->
options
,
$this
->
defineOptions
());
$this
->
view
=
&
$view
;
$this
->
display
=
&
$display
;
...
...
lib/Drupal/views/Plugin/views/style/StylePluginBase.php
View file @
b88ea073
...
...
@@ -90,6 +90,7 @@ abstract class StylePluginBase extends PluginBase {
* from at least two locations. If it's not included, look on the display.
*/
public
function
init
(
&
$view
,
&
$display
,
$options
=
NULL
)
{
$this
->
setOptionDefaults
(
$this
->
options
,
$this
->
defineOptions
());
$this
->
view
=
&
$view
;
$this
->
display
=
&
$display
;
...
...
lib/Drupal/views/Tests/HandlersTest.php
View file @
b88ea073
...
...
@@ -67,7 +67,7 @@ function test_views_break_phrase_string() {
$this
->
assertEqual
(
$empty_stdclass
,
views_break_phrase_string
(
''
,
$null
));
$handler
=
views_get_handler
(
'node'
,
'title'
,
'argument'
);
$this
->
assertEqual
(
$handler
,
views_break_phrase_string
(
''
,
$handler
));
$this
->
assertEqual
(
$handler
,
views_break_phrase_string
(
''
,
$handler
)
,
'The views_break_phrase_string() works correctly.'
);
// test ors
$handler
=
views_break_phrase_string
(
'word1 word2+word'
);
...
...
@@ -122,7 +122,7 @@ function test_views_break_phrase() {
$this
->
assertEqual
(
$empty_stdclass
,
views_break_phrase
(
''
,
$null
));
$handler
=
views_get_handler
(
'node'
,
'title'
,
'argument'
);
$this
->
assertEqual
(
$handler
,
views_break_phrase
(
''
,
$handler
));
$this
->
assertEqual
(
$handler
,
views_break_phrase
(
''
,
$handler
)
,
'The views_break_phrase() function works correctly.'
);
// Generate three random numbers which can be used below;
$n1
=
rand
(
0
,
100
);
...
...
Prev
1
2
Next
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