Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
300
Merge Requests
300
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
1d7dd18c
Commit
1d7dd18c
authored
Sep 05, 2012
by
aspilicious
Committed by
tim.plunkett
Oct 21, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#1765984
by aspilicious: Add standardized helper functions for creating a plugin instance.
parent
b558c592
Changes
24
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
136 additions
and
143 deletions
+136
-143
includes/admin.inc
includes/admin.inc
+6
-8
includes/cache.inc
includes/cache.inc
+0
-26
includes/handlers.inc
includes/handlers.inc
+19
-44
lib/Drupal/views/Plugin/Type/ViewsPluginManager.php
lib/Drupal/views/Plugin/Type/ViewsPluginManager.php
+49
-0
lib/Drupal/views/Plugin/ctools/export_ui/ViewsUI.php
lib/Drupal/views/Plugin/ctools/export_ui/ViewsUI.php
+1
-1
lib/Drupal/views/Plugin/views/argument/ArgumentPluginBase.php
...Drupal/views/Plugin/views/argument/ArgumentPluginBase.php
+3
-3
lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
+3
-8
lib/Drupal/views/Plugin/views/relationship/GroupwiseMax.php
lib/Drupal/views/Plugin/views/relationship/GroupwiseMax.php
+1
-1
lib/Drupal/views/Plugin/views/relationship/RelationshipPluginBase.php
...iews/Plugin/views/relationship/RelationshipPluginBase.php
+1
-1
lib/Drupal/views/Plugin/views/sort/MenuHierarchy.php
lib/Drupal/views/Plugin/views/sort/MenuHierarchy.php
+1
-1
lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php
lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php
+1
-3
lib/Drupal/views/Tests/Plugin/AccessTest.php
lib/Drupal/views/Tests/Plugin/AccessTest.php
+2
-2
lib/Drupal/views/Tests/TranslatableTest.php
lib/Drupal/views/Tests/TranslatableTest.php
+2
-1
lib/Drupal/views/View.php
lib/Drupal/views/View.php
+1
-3
lib/Drupal/views/ViewStorage.php
lib/Drupal/views/ViewStorage.php
+1
-1
lib/Views/comment/Plugin/views/field/NcsLastCommentName.php
lib/Views/comment/Plugin/views/field/NcsLastCommentName.php
+1
-1
lib/Views/comment/Plugin/views/sort/NcsLastCommentName.php
lib/Views/comment/Plugin/views/sort/NcsLastCommentName.php
+1
-1
lib/Views/field/Plugin/views/relationship/EntityReverse.php
lib/Views/field/Plugin/views/relationship/EntityReverse.php
+2
-2
lib/Views/search/Plugin/views/argument/Search.php
lib/Views/search/Plugin/views/argument/Search.php
+1
-1
lib/Views/search/Plugin/views/filter/Search.php
lib/Views/search/Plugin/views/filter/Search.php
+1
-1
lib/Views/taxonomy/Plugin/views/relationship/NodeTermData.php
...Views/taxonomy/Plugin/views/relationship/NodeTermData.php
+1
-1
lib/Views/translation/Plugin/views/relationship/Translation.php
...ews/translation/Plugin/views/relationship/Translation.php
+1
-1
views.module
views.module
+34
-24
views_ui.module
views_ui.module
+3
-8
No files found.
includes/admin.inc
View file @
1d7dd18c
...
...
@@ -9,7 +9,6 @@
use
Drupal\views\TempStore\UserTempStore
;
use
Drupal\views\View
;
use
Drupal\views\Analyzer
;
use
Drupal\views\Plugin\Type\ViewsPluginManager
;
use
Drupal\views\Plugin\views\wizard\WizardException
;
/**
...
...
@@ -348,9 +347,9 @@ function views_ui_add_form($form, &$form_state) {
$wizard_key
=
$show_form
[
'wizard_key'
][
'#default_value'
];
views_include_handlers
();
$
manager
=
new
ViewsPluginManager
(
'wizard'
);
$
info
=
$manager
->
getDefinition
(
$wizard_key
);
$wizard_instance
=
$manager
->
createInstance
(
$wizard_key
,
$info
);
$
info
=
views_get_plugin_definition
(
'wizard'
,
$wizard_key
);
$
wizard_instance
=
views_get_plugin_instance
(
$wizard_key
,
$info
);
$form
=
$wizard_instance
->
build_form
(
$form
,
$form_state
);
$form
[
'save'
]
=
array
(
...
...
@@ -656,10 +655,9 @@ function views_ui_nojs_submit($form, &$form_state) {
*/
function
views_ui_wizard_form_validate
(
$form
,
&
$form_state
)
{
$wizard
=
views_ui_get_wizard
(
$form_state
[
'values'
][
'show'
][
'wizard_key'
]);
$manager
=
new
ViewsPluginManager
(
'wizard'
);
$definition
=
$manager
->
getDefinition
(
$wizard
[
'id'
]);
$definition
=
views_get_plugin_definition
(
'wizard'
,
$wizard
[
'id'
]);
$form_state
[
'wizard'
]
=
$wizard
;
$form_state
[
'wizard_instance'
]
=
$manager
->
createI
nstance
(
$wizard
[
'id'
],
$definition
);
$form_state
[
'wizard_instance'
]
=
views_get_plugin_i
nstance
(
$wizard
[
'id'
],
$definition
);
$errors
=
$form_state
[
'wizard_instance'
]
->
validate
(
$form
,
$form_state
);
foreach
(
$errors
as
$name
=>
$message
)
{
form_set_error
(
$name
,
$message
);
...
...
@@ -1521,7 +1519,7 @@ function views_ui_get_display_tab_details($view, $display) {
'#attributes'
=>
array
(
'id'
=>
'edit-display-settings-details'
),
);
$plugin
=
views_
fetch_plugin_data
(
'display'
,
$view
->
display
[
$display
->
id
]
->
display_plugin
);
$plugin
=
views_
get_plugin_definition
(
'display'
,
$view
->
display
[
$display
->
id
]
->
display_plugin
);
// The following is for display purposes only. We need to determine if there is more than one button and wrap
// the buttons in a .ctools-dropbutton class if more than one is present. Otherwise, we'll just wrap the
// actions in the .ctools-button class.
...
...
includes/cache.inc
View file @
1d7dd18c
...
...
@@ -5,8 +5,6 @@
* Load Views' data so that it knows what is available to build queries from.
*/
use
Drupal\views\Plugin\Type\ViewsPluginManager
;
/**
* Fetch Views' data from the cache
*
...
...
@@ -85,30 +83,6 @@ function _views_data_process_entity_types(&$data) {
}
}
/**
* Fetch the plugin data from cache.
*/
function
_views_fetch_plugin_data
(
$type
=
NULL
,
$id
=
NULL
,
$reset
=
FALSE
)
{
if
(
!
$type
&&
!
$id
)
{
$plugins
=
array
();
$plugin_types
=
array
(
'access'
,
'area'
,
'argument'
,
'argument_default'
,
'argument_validator'
,
'cache'
,
'display_extender'
,
'display'
,
'exposed_form'
,
'field'
,
'filter'
,
'join'
,
'localization'
,
'pager'
,
'query'
,
'relationship'
,
'row'
,
'sort'
,
'style'
,
'wizard'
);
foreach
(
$plugin_types
as
$plugin_type
)
{
$manager
=
new
ViewsPluginManager
(
$plugin_type
);
$plugins
[
$plugin_type
]
=
$manager
->
getDefinitions
();
}
return
$plugins
;
}
$manager
=
new
ViewsPluginManager
(
$type
);
if
(
!
$id
)
{
return
$manager
->
getDefinitions
();
}
else
{
return
$manager
->
getDefinition
(
$id
);
}
}
/**
* Set a cached item in the views cache.
*
...
...
includes/handlers.inc
View file @
1d7dd18c
...
...
@@ -6,51 +6,8 @@
*/
use
Drupal\Core\Database\Database
;
use
Drupal\views\Plugin\Type\ViewsPluginManager
;
use
Drupal\Component\Plugin\Exception\PluginException
;
/**
* Instantiate and construct a new plugin.
*/
function
_views_create_plugin
(
$type
,
$definition
)
{
$manager
=
new
ViewsPluginManager
(
$type
);
$instance
=
$manager
->
createInstance
(
$definition
[
'id'
]);
$instance
->
is_plugin
=
TRUE
;
$instance
->
plugin_type
=
$type
;
$instance
->
setDefinition
(
$definition
);
// Let the handler have something like a constructor.
$instance
->
construct
();
return
$instance
;
}
/**
* Instantiate and construct a new handler
*/
function
_views_create_handler
(
$type
,
$definition
)
{
$manager
=
new
ViewsPluginManager
(
$type
);
// @todo This is crazy. Find a way to remove the override functionality.
$id
=
!
empty
(
$definition
[
'override handler'
])
?
$definition
[
'override handler'
]
:
$definition
[
'id'
];
try
{
$instance
=
$manager
->
createInstance
(
$id
);
}
catch
(
PluginException
$e
)
{
$instance
=
$manager
->
createInstance
(
$definition
[
'id'
]);
}
$instance
->
is_handler
=
TRUE
;
$instance
->
plugin_type
=
$type
;
$instance
->
setDefinition
(
$definition
);
// let the handler have something like a constructor.
$instance
->
construct
();
return
$instance
;
}
/**
* Prepare a handler's data by checking defaults and such.
*/
...
...
@@ -71,6 +28,24 @@ function _views_prepare_handler($definition, $data, $field, $type) {
return
_views_create_handler
(
$type
,
$definition
);
}
/**
* Get a handler for a plugin
*
* @param string $type
* The plugin type like access or display.
* @param string $id
* The name of the plugin like standard.
*
* @return views_plugin
*
* The created plugin object.
*/
function
_views_create_handler
(
$type
,
$definition
)
{
$manager
=
new
ViewsPluginManager
(
$type
);
$plugin
=
$manager
->
createHandlerFromDefinition
(
$definition
);
return
$plugin
;
}
/**
* Fetch a handler to join one table to a primary table from the data cache
*/
...
...
@@ -84,7 +59,7 @@ function views_get_table_join($table, $base_table) {
else
{
$id
=
'standard'
;
}
$handler
=
views_get_
join
(
$id
);
$handler
=
views_get_
plugin_instance
(
'join'
,
$id
);
// Fill in some easy defaults
$handler
->
definition
=
$h
;
...
...
lib/Drupal/views/Plugin/Type/ViewsPluginManager.php
View file @
1d7dd18c
...
...
@@ -73,4 +73,53 @@ public function processDefinition(&$definition, $plugin_id) {
);
}
/**
* Creates a plugin from an id.
*/
public
function
createPluginFromId
(
$id
)
{
$definition
=
$this
->
getDefinition
(
$id
);
if
(
!
empty
(
$definition
))
{
$plugin
=
$this
->
createPluginFromDefinition
(
$defintion
);
return
$plugin
;
}
}
/**
* Creates a plugin from a definition.
*/
public
function
createPluginFromDefinition
(
$definition
)
{
$instance
=
$this
->
createInstance
(
$definition
[
'id'
]);
$instance
->
is_plugin
=
TRUE
;
$instance
->
plugin_type
=
$this
->
$type
;
$instance
->
setDefinition
(
$definition
);
// Let the handler have something like a constructor.
$instance
->
construct
();
return
$instance
;
}
/**
* Creates a handler from a definition.
*/
public
function
createHandlerFromDefinition
(
$definition
)
{
// @todo This is crazy. Find a way to remove the override functionality.
$id
=
!
empty
(
$definition
[
'override handler'
])
?
$definition
[
'override handler'
]
:
$definition
[
'id'
];
try
{
$instance
=
$this
->
createInstance
(
$id
);
}
catch
(
PluginException
$e
)
{
$instance
=
$this
->
createInstance
(
$definition
[
'id'
]);
}
$instance
->
is_handler
=
TRUE
;
$instance
->
plugin_type
=
$this
->
$type
;
$instance
->
setDefinition
(
$definition
);
// let the handler have something like a constructor.
$instance
->
construct
();
return
$instance
;
}
}
lib/Drupal/views/Plugin/ctools/export_ui/ViewsUI.php
View file @
1d7dd18c
...
...
@@ -184,7 +184,7 @@ function list_form(&$form, &$form_state) {
);
$displays
=
array
();
foreach
(
views_
fetch_plugin_data
(
'display'
)
as
$id
=>
$info
)
{
foreach
(
views_
get_plugin_definitions
(
'display'
)
as
$id
=>
$info
)
{
if
(
!
empty
(
$info
[
'admin'
]))
{
$displays
[
$id
]
=
$info
[
'admin'
];
}
...
...
lib/Drupal/views/Plugin/views/argument/ArgumentPluginBase.php
View file @
1d7dd18c
...
...
@@ -303,7 +303,7 @@ public function buildOptionsForm(&$form, &$form_state) {
);
$validate_types
=
array
(
'none'
=>
t
(
'- Basic validation -'
));
$plugins
=
views_
fetch_plugin_data
(
'argument_validator'
);
$plugins
=
views_
get_plugin_definitions
(
'argument_validator'
);
foreach
(
$plugins
as
$id
=>
$info
)
{
if
(
!
empty
(
$info
[
'no_ui'
]))
{
continue
;
...
...
@@ -498,7 +498,7 @@ function default_actions($which = NULL) {
* default action is set to provide default argument.
*/
function
default_argument_form
(
&
$form
,
&
$form_state
)
{
$plugins
=
views_
fetch_plugin_data
(
'argument_default'
);
$plugins
=
views_
get_plugin_definitions
(
'argument_default'
);
$options
=
array
();
$form
[
'default_argument_skip_url'
]
=
array
(
...
...
@@ -562,7 +562,7 @@ function default_argument_form(&$form, &$form_state) {
* default action is set to display one.
*/
function
default_summary_form
(
&
$form
,
&
$form_state
)
{
$style_plugins
=
views_
fetch_plugin_data
(
'style'
);
$style_plugins
=
views_
get_plugin_definitions
(
'style'
);
$summary_plugins
=
array
();
$format_options
=
array
();
foreach
(
$style_plugins
as
$key
=>
$plugin
)
{
...
...
lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
View file @
1d7dd18c
...
...
@@ -9,7 +9,6 @@
use
Drupal\views\View
;
use
Drupal\views\Plugin\views\PluginBase
;
use
Drupal\views\Plugin\Type\ViewsPluginManager
;
/**
* @defgroup views_display_plugins Views display plugins
...
...
@@ -818,8 +817,7 @@ public function getPlugin($type = 'style', $name = NULL) {
$plugin
=
views_get_plugin
(
$type
,
$name
);
}
else
{
$plugin_type
=
new
ViewsPluginManager
(
'query'
);
$plugin
=
$plugin_type
->
createInstance
(
$name
);
$plugin
=
views_get_plugin_instance
(
'query'
,
$name
);
}
if
(
!
$plugin
)
{
...
...
@@ -1116,9 +1114,8 @@ public function optionsSummary(&$categories, &$options) {
'desc'
=>
t
(
'Change the title that this display will use.'
),
);
$manager
=
new
ViewsPluginManager
(
'style'
);
$name
=
$this
->
getOption
(
'style_plugin'
);
$style_plugin
=
$manager
->
getDefinition
(
$name
);
$style_plugin
=
views_get_plugin_definition
(
'style'
,
$name
);
$style_plugin_instance
=
$this
->
getPlugin
(
'style'
,
$name
);
$style_summary
=
empty
(
$style_plugin
[
'title'
])
?
t
(
'Missing style plugin'
)
:
$style_plugin_instance
->
summaryTitle
();
$style_title
=
empty
(
$style_plugin
[
'title'
])
?
t
(
'Missing style plugin'
)
:
$style_plugin_instance
->
pluginTitle
();
...
...
@@ -1139,9 +1136,8 @@ public function optionsSummary(&$categories, &$options) {
}
if
(
$style_plugin_instance
->
usesRowPlugin
())
{
$manager
=
new
ViewsPluginManager
(
'row'
);
$name
=
$this
->
getOption
(
'row_plugin'
);
$row_plugin
=
$manager
->
getDefinition
(
$name
);
$row_plugin
=
views_get_plugin_definition
(
'row'
,
$name
);
$row_plugin_instance
=
$this
->
getPlugin
(
'row'
,
$name
);
$row_summary
=
empty
(
$row_plugin
[
'title'
])
?
t
(
'Missing style plugin'
)
:
$row_plugin_instance
->
summaryTitle
();
$row_title
=
empty
(
$row_plugin
[
'title'
])
?
t
(
'Missing style plugin'
)
:
$row_plugin_instance
->
pluginTitle
();
...
...
@@ -1639,7 +1635,6 @@ public function buildOptionsForm(&$form, &$form_state) {
}
break
;
case
'style_plugin'
:
$manager
=
new
ViewsPluginManager
(
'style'
);
$form
[
'#title'
]
.
=
t
(
'How should this view be styled'
);
$form
[
'style_plugin'
]
=
array
(
'#type'
=>
'radios'
,
...
...
lib/Drupal/views/Plugin/views/relationship/GroupwiseMax.php
View file @
1d7dd18c
...
...
@@ -377,7 +377,7 @@ public function query() {
else
{
$id
=
'subquery'
;
}
$join
=
views_get_
join
(
$id
);
$join
=
views_get_
plugin_instance
(
'join'
,
$id
);
$join
->
definition
=
$def
;
$join
->
construct
();
...
...
lib/Drupal/views/Plugin/views/relationship/RelationshipPluginBase.php
View file @
1d7dd18c
...
...
@@ -138,7 +138,7 @@ public function query() {
else
{
$id
=
'standard'
;
}
$join
=
views_get_
join
(
$id
);
$join
=
views_get_
plugin_instance
(
'join'
,
$id
);
$join
->
definition
=
$def
;
$join
->
options
=
$this
->
options
;
...
...
lib/Drupal/views/Plugin/views/sort/MenuHierarchy.php
View file @
1d7dd18c
...
...
@@ -46,7 +46,7 @@ public function query() {
$max_depth
=
isset
(
$this
->
definition
[
'max depth'
])
?
$this
->
definition
[
'max depth'
]
:
MENU_MAX_DEPTH
;
for
(
$i
=
1
;
$i
<=
$max_depth
;
++
$i
)
{
if
(
$this
->
options
[
'sort_within_level'
])
{
$join
=
views_get_
join
(
);
$join
=
views_get_
plugin_instance
(
'join'
);
$join
->
construct
(
'menu_links'
,
$this
->
table_alias
,
$this
->
field
.
$i
,
'mlid'
);
$menu_links
=
$this
->
query
->
add_table
(
'menu_links'
,
NULL
,
$join
);
$this
->
query
->
add_orderby
(
$menu_links
,
'weight'
,
$this
->
options
[
'order'
]);
...
...
lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php
View file @
1d7dd18c
...
...
@@ -9,7 +9,6 @@
use
Drupal\views\View
;
use
Drupal\views\Plugin\views\wizard\WizardInterface
;
use
Drupal\views\Plugin\Type\ViewsPluginManager
;
/**
* Provides the interface and base class for Views Wizard plugins.
...
...
@@ -749,8 +748,7 @@ protected function default_display_filters_user($form, $form_state) {
$table_data
=
views_fetch_data
(
$table
);
// If the 'in' operator is being used, map the values to an array.
$handler
=
$table_data
[
$bundle_key
][
'filter'
][
'id'
];
$plugin_manager
=
new
ViewsPluginManager
(
'filter'
);
$handler_definition
=
$plugin_manager
->
getDefinition
(
$handler
);
$handler_definition
=
views_get_plugin_definition
(
'filter'
,
$handler
);
if
(
$handler
==
'in_operator'
||
is_subclass_of
(
$handler_definition
[
'class'
],
'Drupal\\views\\Plugin\\views\\filter\\InOperator'
))
{
$value
=
drupal_map_assoc
(
array
(
$form_state
[
'values'
][
'show'
][
'type'
]));
}
...
...
lib/Drupal/views/Tests/Plugin/AccessTest.php
View file @
1d7dd18c
...
...
@@ -32,8 +32,8 @@ protected function setUp() {
$this
->
normal_role
=
$this
->
drupalCreateRole
(
array
());
$this
->
normal_user
=
$this
->
drupalCreateUser
(
array
(
'views_test test permission'
));
$this
->
normal_user
->
roles
[
$this
->
normal_role
]
=
$this
->
normal_role
;
//
Reset the plugin data.
views_fetch_plugin_data
(
NULL
,
NULL
,
TRUE
);
//
@todo when all the plugin information is cached make a reset function and
// call it here.
}
/**
...
...
lib/Drupal/views/Tests/TranslatableTest.php
View file @
1d7dd18c
...
...
@@ -32,7 +32,8 @@ protected function setUp() {
config
(
'views.settings'
)
->
set
(
'localization_plugin'
,
'test_localization'
)
->
save
();
// Reset the plugin data.
views_fetch_plugin_data
(
NULL
,
NULL
,
TRUE
);
// @todo when all the plugin information is cached make a reset function and
// call it here.
$this
->
strings
=
array
(
'Master1'
,
'Apply1'
,
...
...
lib/Drupal/views/View.php
View file @
1d7dd18c
...
...
@@ -8,7 +8,6 @@
namespace
Drupal\views
;
use
Symfony\Component\HttpFoundation\Response
;
use
Drupal\views\Plugin\Type\ViewsPluginManager
;
/**
* @defgroup views_objects Objects that represent a View or part of a view
...
...
@@ -1047,8 +1046,7 @@ public function initQuery() {
// Create and initialize the query object.
$plugin
=
!
empty
(
$views_data
[
'table'
][
'base'
][
'query class'
])
?
$views_data
[
'table'
][
'base'
][
'query class'
]
:
'views_query'
;
$plugin_type
=
new
ViewsPluginManager
(
'query'
);
$this
->
query
=
$plugin_type
->
createInstance
(
$plugin
);
$this
->
query
=
views_get_plugin_instance
(
'query'
,
$plugin
);
if
(
empty
(
$this
->
query
))
{
return
FALSE
;
...
...
lib/Drupal/views/ViewStorage.php
View file @
1d7dd18c
...
...
@@ -63,7 +63,7 @@ public function addDisplay($plugin_id = 'page', $title = NULL, $id = NULL) {
return
FALSE
;
}
$plugin
=
views_
fetch_plugin_data
(
'display'
,
$plugin_id
);
$plugin
=
views_
get_plugin_definition
(
'display'
,
$plugin_id
);
if
(
empty
(
$plugin
))
{
$plugin
[
'title'
]
=
t
(
'Broken'
);
}
...
...
lib/Views/comment/Plugin/views/field/NcsLastCommentName.php
View file @
1d7dd18c
...
...
@@ -27,7 +27,7 @@ public function query() {
// have to join in a specially related user table.
$this
->
ensureMyTable
();
// join 'users' to this table via vid
$join
=
views_get_
join
(
);
$join
=
views_get_
plugin_instance
(
'join'
);
$join
->
construct
(
'users'
,
$this
->
table_alias
,
'last_comment_uid'
,
'uid'
);
$join
->
extra
=
array
(
array
(
'field'
=>
'uid'
,
'operator'
=>
'!='
,
'value'
=>
'0'
));
...
...
lib/Views/comment/Plugin/views/sort/NcsLastCommentName.php
View file @
1d7dd18c
...
...
@@ -25,7 +25,7 @@ class NcsLastCommentName extends SortPluginBase {
public
function
query
()
{
$this
->
ensureMyTable
();
$join
=
views_get_
join
(
);
$join
=
views_get_
plugin_instance
(
'join'
);
$join
->
construct
(
'users'
,
$this
->
table_alias
,
'last_comment_uid'
,
'uid'
);
// @todo this might be safer if we had an ensure_relationship rather than guessing
...
...
lib/Views/field/Plugin/views/relationship/EntityReverse.php
View file @
1d7dd18c
...
...
@@ -58,7 +58,7 @@ public function query() {
else
{
$id
=
'standard'
;
}
$first_join
=
views_get_
join
(
$id
);
$first_join
=
views_get_
plugin_instance
(
'join'
,
$id
);
$first_join
->
definition
=
$first
;
$first_join
->
construct
();
...
...
@@ -85,7 +85,7 @@ public function query() {
else
{
$id
=
'standard'
;
}
$second_join
=
views_get_
join
(
$id
);
$second_join
=
views_get_
plugin_instance
(
'join'
,
$id
);
$second_join
->
definition
=
$second
;
$second_join
->
construct
();
$second_join
->
adjusted
=
TRUE
;
...
...
lib/Views/search/Plugin/views/argument/Search.php
View file @
1d7dd18c
...
...
@@ -62,7 +62,7 @@ public function query($group_by = FALSE) {
$search_condition
=
db_and
();
// Create a new join to relate the 'search_total' table to our current 'search_index' table.
$join
=
views_get_
join
(
);
$join
=
views_get_
plugin_instance
(
'join'
);
$join
->
construct
(
'search_total'
,
$search_index
,
'word'
,
'word'
);
$search_total
=
$this
->
query
->
add_relationship
(
'search_total'
,
$join
,
$search_index
);
...
...
lib/Views/search/Plugin/views/filter/Search.php
View file @
1d7dd18c
...
...
@@ -142,7 +142,7 @@ public function query() {
$search_condition
=
db_and
();
// Create a new join to relate the 'serach_total' table to our current 'search_index' table.
$join
=
views_get_
join
(
);
$join
=
views_get_
plugin_instance
(
'join'
);
$join
->
construct
(
'search_total'
,
$search_index
,
'word'
,
'word'
);
$search_total
=
$this
->
query
->
add_relationship
(
'search_total'
,
$join
,
$search_index
);
...
...
lib/Views/taxonomy/Plugin/views/relationship/NodeTermData.php
View file @
1d7dd18c
...
...
@@ -92,7 +92,7 @@ public function query() {
$def
[
'table formula'
]
=
$query
;
}
$join
=
views_get_
join
(
'standard
'
);
$join
=
views_get_
plugin_instance
(
'join
'
);
$join
->
definition
=
$def
;
$join
->
construct
();
...
...
lib/Views/translation/Plugin/views/relationship/Translation.php
View file @
1d7dd18c
...
...
@@ -101,7 +101,7 @@ public function query() {
else
{
$id
=
'standard'
;
}
$join
=
views_get_
join
(
$id
);
$join
=
views_get_
plugin_instance
(
'join'
,
$id
);
$join
->
definition
=
$def
;
$join
->
construct
();
...
...
views.module
View file @
1d7dd18c
...
...
@@ -186,7 +186,7 @@ function views_theme($existing, $type, $theme, $path) {
'variables'
=>
array
(
'view'
=>
NULL
,
'grouping'
=>
NULL
,
'grouping_level'
=>
NULL
,
'rows'
=>
NULL
,
'title'
=>
NULL
),
);
$plugins
=
views_
fetch_plugin_data
();
$plugins
=
views_
get_plugin_definitions
();
// Register theme functions for all style plugins
foreach
(
$plugins
as
$type
=>
$info
)
{
...
...
@@ -346,7 +346,7 @@ function _views_find_module_templates($cache, $path) {
* keyed by machine name.
*/
function
views_plugin_list
()
{
$plugin_data
=
views_
fetch_plugin_data
();
$plugin_data
=
views_
get_plugin_definitions
();
$plugins
=
array
();
foreach
(
views_get_enabled_views
()
as
$view
)
{
foreach
(
$view
->
display
as
$display_id
=>
$display
)
{
...
...
@@ -910,7 +910,7 @@ function views_add_contextual_links(&$render_element, $location, $view, $display
// Also do not do anything if the display plugin has not defined any
// contextual links that are intended to be displayed in the requested
// location.
$plugin
=
views_
fetch_plugin_data
(
'display'
,
$view
->
display
[
$display_id
]
->
display_plugin
);
$plugin
=
views_
get_plugin_defintion
(
'display'
,
$view
->
display
[
$display_id
]
->
display_plugin
);
// If contextual_links_locations are not set, provide a sane default. (To
// avoid displaying any contextual links at all, a display plugin can still
// set 'contextual_links_locations' to, e.g., {""}.)
...
...
@@ -1277,7 +1277,7 @@ function views_include_handlers($reset = FALSE) {
function
views_get_handler
(
$table
,
$field
,
$key
,
$override
=
NULL
)
{
static
$recursion_protection
=
array
();
$data
=
views_
fetch_data
(
$table
,
FALSE
);
$data
=
views_
get_plugin_definitions
(
$table
);
$handler
=
NULL
;
views_include
(
'handlers'
);
...
...
@@ -1358,14 +1358,6 @@ function views_fetch_data($table = NULL, $move = TRUE, $reset = FALSE) {
// -----------------------------------------------------------------------
// Views plugin functions
/**
* Fetch the plugin data from cache.
*/
function
views_fetch_plugin_data
(
$type
=
NULL
,
$id
=
NULL
,
$reset
=
FALSE
)
{
views_include
(
'cache'
);
return
_views_fetch_plugin_data
(
$type
,
$id
,
$reset
);
}
/**
* Fetch a list of all base tables available
*
...
...
@@ -1381,8 +1373,7 @@ function views_fetch_plugin_data($type = NULL, $id = NULL, $reset = FALSE) {
* A keyed array of in the form of 'base_table' => 'Description'.
*/
function
views_fetch_plugin_names
(
$type
,
$key
=
NULL
,
$base
=
array
())
{
$manager
=
new
ViewsPluginManager
(
$type
);
$definitions
=
$manager
->
getDefinitions
();
$definitions
=
views_get_plugin_definitions
(
$type
);
$plugins
=
array
();
foreach
(
$definitions
as
$id
=>
$plugin
)
{
...
...
@@ -1422,14 +1413,33 @@ function views_fetch_plugin_names($type, $key = NULL, $base = array()) {
*
* The created plugin object.
*/
function
views_get_plugin
(
$type
,
$id
,
$reset
=
FALSE
)
{
views_include
(
'handlers'
);
function
views_get_plugin
(
$type
,
$id
)
{
$manager
=
new
ViewsPluginManager
(
$type
);
$definition
=
$manager
->
getDefinition
(
$id
);
if
(
!
empty
(
$definition
))
{
return
_views_create_plugin
(
$type
,
$definition
);
$manager
->
createPluginFromId
(
$id
);
}
/**
* Gets all the views plugin definitions
*/
function
views_get_plugin_definitions
(
$type
=
FALSE
)
{
$plugins
=
array
();
$plugin_types
=
$type
?
array
(
$type
)
:
array
(
'access'
,
'area'
,
'argument'
,
'argument_default'
,
'argument_validator'
,
'cache'
,
'display_extender'
,
'display'
,
'exposed_form'
,
'field'
,
'filter'
,
'join'
,
'localization'
,
'pager'
,
'query'
,
'relationship'
,
'row'
,
'sort'
,
'style'
,
'wizard'
);
foreach
(
$plugin_types
as
$plugin_type
)
{
$manager
=
new
ViewsPluginManager
(
$plugin_type
);
$plugins
[
$plugin_type
]
=
$manager
->
getDefinitions
();
}
if
(
$type
)
{
return
$plugins
[
$type
];
}
return
$plugins
;
}
/**
* Gets the plugin definition from a plugin type with a specific id.
*/
function
views_get_plugin_definition
(
$type
,
$id
)
{
$manager
=
new
ViewsPluginManager
(
$type
);
return
$manager
->
getDefintion
(
$id
);
}
/**
...
...
@@ -1440,9 +1450,9 @@ function views_get_plugin($type, $id, $reset = FALSE) {
*
* @return Drupal\views\Plugin\views\join\JoinPluginBase
*/
function
views_get_
join
(
$plugin_id
=
'standard'
)
{
$manager
=
new
ViewsPluginManager
(
'join'
);
return
$manager
->
createInstance
(
$plugin_id
);
function
views_get_
plugin_instance
(
$type
,
$plugin_id
=
'standard'
,
array
$configuration
=
array
()
)
{
$manager
=
new
ViewsPluginManager
(
$type
);
return
$manager
->
createInstance
(
$plugin_id
,
$configuration
);
}
/**
...
...
@@ -1547,7 +1557,7 @@ function views_get_applicable_views($type) {
// Loop on array keys because something seems to muck with $view->display
// a bit in PHP4.
foreach
(
array_keys
(
$view
->
display
)
as
$id
)
{
$plugin
=
views_
fetch_plugin_data
(
'display'
,
$view
->
display
[
$id
]
->
display_plugin
);
$plugin
=
views_
get_plugin_defintion
(
'display'
,
$view
->
display
[
$id
]
->
display_plugin
);
if
(
!
empty
(
$plugin
[
$type
]))
{
// This view uses_hook_menu. Clone it so that different handlers
// don't trip over each other, and add it to the list.
...
...
views_ui.module