Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
b2970df1
Commit
b2970df1
authored
Jul 29, 2012
by
Tim Plunkett
Browse files
Remove views_get_plugin_manager() and replace with new ViewsPluginManager().
parent
427ec64d
Changes
21
Hide whitespace changes
Inline
Side-by-side
includes/admin.inc
View file @
b2970df1
...
...
@@ -8,7 +8,7 @@
use
Drupal\Core\Database\Database
;
use
Drupal\views\View
;
use
Drupal\views\Analyzer
;
use
Drupal\views\Plugin\Type\
Wizard
Manager
;
use
Drupal\views\Plugin\Type\
ViewsPlugin
Manager
;
/**
* Create an array of Views admin CSS for adding or attaching.
...
...
@@ -381,7 +381,7 @@ function views_ui_add_form($form, &$form_state) {
$wizard_key
=
$show_form
[
'wizard_key'
][
'#default_value'
];
views_include_handlers
();
$manager
=
views_get_p
lugin
_m
anager
(
'wizard'
);
$manager
=
new
ViewsP
lugin
M
anager
(
'wizard'
);
$info
=
$manager
->
getDefinition
(
$wizard_key
);
$wizard_instance
=
$manager
->
createInstance
(
$wizard_key
,
$info
);
$form
=
$wizard_instance
->
build_form
(
$form
,
$form_state
);
...
...
@@ -705,7 +705,7 @@ 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
=
views_get_p
lugin
_m
anager
(
'wizard'
);
$manager
=
new
ViewsP
lugin
M
anager
(
'wizard'
);
$definition
=
$manager
->
getDefinition
(
$wizard
[
'plugin_id'
]);
$form_state
[
'wizard'
]
=
$wizard
;
$form_state
[
'wizard_instance'
]
=
$manager
->
createInstance
(
$wizard
[
'plugin_id'
],
$definition
);
...
...
includes/cache.inc
View file @
b2970df1
...
...
@@ -5,6 +5,8 @@
* 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
*
...
...
@@ -91,13 +93,13 @@ function _views_fetch_plugin_data($type = NULL, $plugin_id = NULL, $reset = FALS
$plugins
=
array
();
$plugin_types
=
array
(
'access'
,
'argument_default'
,
'argument_validator'
,
'cache'
,
'display_extender'
,
'display'
,
'exposed_form'
,
'localization'
,
'pager'
,
'query'
,
'row'
,
'style'
,
'wizard'
);
foreach
(
$plugin_types
as
$plugin_type
)
{
$manager
=
views_get_p
lugin
_m
anager
(
$plugin_type
);
$manager
=
new
ViewsP
lugin
M
anager
(
$plugin_type
);
$plugins
[
$plugin_type
]
=
$manager
->
getDefinitions
();
}
return
$plugins
;
}
$manager
=
views_get_p
lugin
_m
anager
(
$type
);
$manager
=
new
ViewsP
lugin
M
anager
(
$type
);
if
(
!
$plugin_id
)
{
return
$manager
->
getDefinitions
();
...
...
includes/handlers.inc
View file @
b2970df1
...
...
@@ -9,8 +9,7 @@
use
Drupal\views\View
;
use
Drupal\views\Join
;
use
Drupal\views\ViewsObject
;
use
Drupal\views\Plugin\Type\ViewsPluginManager
;
/**
* Instantiate and construct a new plugin.
...
...
@@ -19,7 +18,7 @@
* Figure out what to keep from _views_create_handler.
*/
function
_views_create_plugin
(
$type
,
$plugin_id
,
$definition
)
{
$manager
=
views_get_p
lugin
_m
anager
(
$type
);
$manager
=
new
ViewsP
lugin
M
anager
(
$type
);
$instance
=
$manager
->
createInstance
(
$plugin_id
);
...
...
@@ -41,7 +40,7 @@ function _views_create_plugin($type, $plugin_id, $definition) {
*/
function
_views_create_handler
(
$definition
,
$type
=
'handler'
,
$handler_type
=
NULL
)
{
if
(
!
empty
(
$definition
[
'plugin_id'
]))
{
$manager
=
views_get_p
lugin
_m
anager
(
$handler_type
);
$manager
=
new
ViewsP
lugin
M
anager
(
$handler_type
);
$handler
=
$manager
->
createInstance
(
$definition
[
'plugin_id'
]);
}
else
{
...
...
lib/Drupal/views/Plugin/Type/AccessPluginManager.php
deleted
100644 → 0
View file @
427ec64d
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\AccessPluginManager.
*/
namespace
Drupal\views\Plugin\Type
;
use
Drupal\Component\Plugin\PluginManagerBase
;
use
Drupal\Component\Plugin\Factory\DefaultFactory
;
use
Drupal\views\Plugin\Discovery\ViewsDiscovery
;
class
AccessPluginManager
extends
PluginManagerBase
{
public
function
__construct
()
{
$this
->
discovery
=
new
ViewsDiscovery
(
'views'
,
'access'
);
$this
->
factory
=
new
DefaultFactory
(
$this
->
discovery
);
}
}
lib/Drupal/views/Plugin/Type/ArgumentDefaultPluginManager.php
deleted
100644 → 0
View file @
427ec64d
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\ArgumentDefaultPluginManager.
*/
namespace
Drupal\views\Plugin\Type
;
use
Drupal\Component\Plugin\PluginManagerBase
;
use
Drupal\Component\Plugin\Factory\DefaultFactory
;
use
Drupal\views\Plugin\Discovery\ViewsDiscovery
;
class
ArgumentDefaultPluginManager
extends
PluginManagerBase
{
public
function
__construct
()
{
$this
->
discovery
=
new
ViewsDiscovery
(
'views'
,
'argument_default'
);
$this
->
factory
=
new
DefaultFactory
(
$this
->
discovery
);
}
}
lib/Drupal/views/Plugin/Type/ArgumentValidatorPluginManager.php
deleted
100644 → 0
View file @
427ec64d
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\ArgumentValidatorPluginManager.
*/
namespace
Drupal\views\Plugin\Type
;
use
Drupal\Component\Plugin\PluginManagerBase
;
use
Drupal\Component\Plugin\Factory\DefaultFactory
;
use
Drupal\views\Plugin\Discovery\ViewsDiscovery
;
class
ArgumentValidatorPluginManager
extends
PluginManagerBase
{
public
function
__construct
()
{
$this
->
discovery
=
new
ViewsDiscovery
(
'views'
,
'argument_validator'
);
$this
->
factory
=
new
DefaultFactory
(
$this
->
discovery
);
}
}
lib/Drupal/views/Plugin/Type/CachePluginManager.php
deleted
100644 → 0
View file @
427ec64d
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\CachePluginManager.
*/
namespace
Drupal\views\Plugin\Type
;
use
Drupal\Component\Plugin\PluginManagerBase
;
use
Drupal\Component\Plugin\Factory\DefaultFactory
;
use
Drupal\views\Plugin\Discovery\ViewsDiscovery
;
class
CachePluginManager
extends
PluginManagerBase
{
public
function
__construct
()
{
$this
->
discovery
=
new
ViewsDiscovery
(
'views'
,
'cache'
);
$this
->
factory
=
new
DefaultFactory
(
$this
->
discovery
);
}
}
lib/Drupal/views/Plugin/Type/DisplayExtenderPluginManager.php
deleted
100644 → 0
View file @
427ec64d
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\DisplayExtenderPluginManager.
*/
namespace
Drupal\views\Plugin\Type
;
use
Drupal\Component\Plugin\PluginManagerBase
;
use
Drupal\Component\Plugin\Factory\DefaultFactory
;
use
Drupal\Views\Plugin\Discovery\ViewsDiscovery
;
class
DisplayExtenderPluginManager
extends
PluginManagerBase
{
public
function
__construct
()
{
$this
->
discovery
=
new
ViewsDiscovery
(
'views'
,
'display_extender'
);
$this
->
factory
=
new
DefaultFactory
(
$this
->
discovery
);
}
}
lib/Drupal/views/Plugin/Type/DisplayPluginManager.php
deleted
100644 → 0
View file @
427ec64d
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\DisplayPluginManager.
*/
namespace
Drupal\views\Plugin\Type
;
use
Drupal\Component\Plugin\PluginManagerBase
;
use
Drupal\Component\Plugin\Factory\DefaultFactory
;
use
Drupal\views\Plugin\Discovery\ViewsDiscovery
;
class
DisplayPluginManager
extends
PluginManagerBase
{
public
function
__construct
()
{
$this
->
discovery
=
new
ViewsDiscovery
(
'views'
,
'display'
);
$this
->
factory
=
new
DefaultFactory
(
$this
->
discovery
);
}
}
lib/Drupal/views/Plugin/Type/ExposedFormPluginManager.php
deleted
100644 → 0
View file @
427ec64d
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\ExposedFormPluginManager.
*/
namespace
Drupal\views\Plugin\Type
;
use
Drupal\Component\Plugin\PluginManagerBase
;
use
Drupal\Component\Plugin\Factory\DefaultFactory
;
use
Drupal\Views\Plugin\Discovery\ViewsDiscovery
;
class
ExposedFormPluginManager
extends
PluginManagerBase
{
public
function
__construct
()
{
$this
->
discovery
=
new
ViewsDiscovery
(
'views'
,
'exposed_form'
);
$this
->
factory
=
new
DefaultFactory
(
$this
);
}
}
lib/Drupal/views/Plugin/Type/LocalizationPluginManager.php
deleted
100644 → 0
View file @
427ec64d
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\LocalizationPluginManager.
*/
namespace
Drupal\views\Plugin\Type
;
use
Drupal\Component\Plugin\PluginManagerBase
;
use
Drupal\Component\Plugin\Factory\DefaultFactory
;
use
Drupal\Views\Plugin\Discovery\ViewsDiscovery
;
class
LocalizationPluginManager
extends
PluginManagerBase
{
public
function
__construct
()
{
$this
->
discovery
=
new
ViewsDiscovery
(
'views'
,
'localization'
);
$this
->
factory
=
new
DefaultFactory
(
$this
);
}
}
lib/Drupal/views/Plugin/Type/PagerPluginManager.php
deleted
100644 → 0
View file @
427ec64d
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\PagerPluginManager.
*/
namespace
Drupal\views\Plugin\Type
;
use
Drupal\Component\Plugin\PluginManagerBase
;
use
Drupal\Component\Plugin\Factory\DefaultFactory
;
use
Drupal\Views\Plugin\Discovery\ViewsDiscovery
;
class
PagerPluginManager
extends
PluginManagerBase
{
public
function
__construct
()
{
$this
->
discovery
=
new
ViewsDiscovery
(
'views'
,
'pager'
);
$this
->
factory
=
new
DefaultFactory
(
$this
);
}
}
lib/Drupal/views/Plugin/Type/QueryPluginManager.php
deleted
100644 → 0
View file @
427ec64d
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\QueryPluginManager.
*/
namespace
Drupal\views\Plugin\Type
;
use
Drupal\Component\Plugin\PluginManagerBase
;
use
Drupal\Component\Plugin\Factory\DefaultFactory
;
use
Drupal\Views\Plugin\Discovery\ViewsDiscovery
;
class
QueryPluginManager
extends
PluginManagerBase
{
public
function
__construct
()
{
$this
->
discovery
=
new
ViewsDiscovery
(
'views'
,
'query'
);
$this
->
factory
=
new
DefaultFactory
(
$this
);
}
}
lib/Drupal/views/Plugin/Type/RowPluginManager.php
deleted
100644 → 0
View file @
427ec64d
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\RowPluginManager.
*/
namespace
Drupal\views\Plugin\Type
;
use
Drupal\Component\Plugin\PluginManagerBase
;
use
Drupal\Component\Plugin\Factory\DefaultFactory
;
use
Drupal\Views\Plugin\Discovery\ViewsDiscovery
;
class
RowPluginManager
extends
PluginManagerBase
{
public
function
__construct
()
{
$this
->
discovery
=
new
ViewsDiscovery
(
'views'
,
'row'
);
$this
->
factory
=
new
DefaultFactory
(
$this
);
}
}
lib/Drupal/views/Plugin/Type/StylePluginManager.php
deleted
100644 → 0
View file @
427ec64d
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\StylePluginManager.
*/
namespace
Drupal\views\Plugin\Type
;
use
Drupal\Component\Plugin\PluginManagerBase
;
use
Drupal\Component\Plugin\Factory\DefaultFactory
;
use
Drupal\Views\Plugin\Discovery\ViewsDiscovery
;
class
StylePluginManager
extends
PluginManagerBase
{
public
function
__construct
()
{
$this
->
discovery
=
new
ViewsDiscovery
(
'views'
,
'style'
);
$this
->
factory
=
new
DefaultFactory
(
$this
);
}
}
lib/Drupal/views/Plugin/Type/
Handler
PluginManager.php
→
lib/Drupal/views/Plugin/Type/
Views
PluginManager.php
View file @
b2970df1
...
...
@@ -2,16 +2,16 @@
/**
* @file
* Definition of Drupal\views\Plugin\Type\
Handler
PluginManager.
* Definition of Drupal\views\Plugin\Type\
Views
PluginManager.
*/
namespace
Drupal\views\Plugin\Type
;
use
Drupal\Component\Plugin\PluginManagerBase
;
use
Drupal\Component\Plugin\Factory\DefaultFactory
;
use
Drupal\
V
iews\Plugin\Discovery\ViewsDiscovery
;
use
Drupal\
v
iews\Plugin\Discovery\ViewsDiscovery
;
class
Handler
PluginManager
extends
PluginManagerBase
{
class
Views
PluginManager
extends
PluginManagerBase
{
/**
* The handler type of this plugin manager, for example filter or field.
*
...
...
lib/Drupal/views/Plugin/Type/WizardPluginManager.php
deleted
100644 → 0
View file @
427ec64d
<?php
/**
* @file
* Definition of Drupal\views\Plugin\Type\WizardPluginManager.
*/
namespace
Drupal\views\Plugin\Type
;
use
Drupal\Component\Plugin\PluginManagerBase
;
use
Drupal\Component\Plugin\Factory\DefaultFactory
;
use
Drupal\views\Plugin\Discovery\ViewsDiscovery
;
class
WizardPluginManager
extends
PluginManagerBase
{
public
function
__construct
()
{
$this
->
discovery
=
new
ViewsDiscovery
(
'views'
,
'wizard'
);
$this
->
factory
=
new
DefaultFactory
(
$this
->
discovery
);
}
}
lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
View file @
b2970df1
...
...
@@ -9,7 +9,7 @@
use
Drupal\views\View
;
use
Drupal\views\Plugin\views\Plugin
;
use
Drupal\views\Plugin\Type\
Query
PluginManager
;
use
Drupal\views\Plugin\Type\
Views
PluginManager
;
/**
* @defgroup views_display_plugins Views display plugins
...
...
@@ -1191,7 +1191,7 @@ function options_summary(&$categories, &$options) {
'desc'
=>
t
(
'Change the title that this display will use.'
),
);
$manager
=
views_get_p
lugin
_m
anager
(
'style'
);
$manager
=
new
ViewsP
lugin
M
anager
(
'style'
);
$style_plugin
=
$manager
->
getDefinition
(
$this
->
get_option
(
'style_plugin'
));
$style_plugin_instance
=
$this
->
get_plugin
(
'style'
);
$style_summary
=
empty
(
$style_plugin
[
'title'
])
?
t
(
'Missing style plugin'
)
:
$style_plugin_instance
->
summary_title
();
...
...
@@ -1213,7 +1213,7 @@ function options_summary(&$categories, &$options) {
}
if
(
!
empty
(
$style_plugin
[
'uses_row_plugin'
]))
{
$manager
=
views_get_p
lugin
_m
anager
(
'row'
);
$manager
=
new
ViewsP
lugin
M
anager
(
'row'
);
$row_plugin
=
$manager
->
getDefinition
(
$this
->
get_option
(
'row_plugin'
));
$row_plugin_instance
=
$this
->
get_plugin
(
'row'
);
$row_summary
=
empty
(
$row_plugin
[
'title'
])
?
t
(
'Missing style plugin'
)
:
$row_plugin_instance
->
summary_title
();
...
...
@@ -1727,7 +1727,7 @@ function options_form(&$form, &$form_state) {
}
break
;
case
'style_plugin'
:
$manager
=
views_get_p
lugin
_m
anager
(
'style'
);
$manager
=
new
ViewsP
lugin
M
anager
(
'style'
);
$form
[
'#title'
]
.
=
t
(
'How should this view be styled'
);
$form
[
'#help_topic'
]
=
'style'
;
$form
[
'style_plugin'
]
=
array
(
...
...
lib/Drupal/views/View.php
View file @
b2970df1
...
...
@@ -8,8 +8,6 @@
namespace
Drupal\views
;
use
Symfony\Component\HttpFoundation\Response
;
use
Drupal\views\Plugin\Type\QueryPluginManager
;
use
Drupal\views\Plugin\Type\DisplayPluginManager
;
/**
* @defgroup views_objects Objects that represent a View or part of a view
...
...
@@ -917,7 +915,7 @@ function init_query() {
// 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
Query
PluginManager
();
$plugin_type
=
new
Views
PluginManager
(
'query'
);
$this
->
query
=
$plugin_type
->
createInstance
(
$plugin
);
if
(
empty
(
$this
->
query
))
{
...
...
views.module
View file @
b2970df1
...
...
@@ -12,22 +12,7 @@
use
Drupal\Core\Database\Query\AlterableInterface
;
use
Drupal\views\View
;
use
Drupal\Component\Plugin\PluginManagerInterface
;
// @todo: Should views_get_plugin_manager be moved to a ceperate file?
use
Drupal\views\Plugin\Type\StylePluginManager
;
use
Drupal\views\Plugin\Type\DisplayPluginManager
;
use
Drupal\views\Plugin\Type\AccessPluginManager
;
use
Drupal\views\Plugin\Type\ArgumentDefaultPluginManager
;
use
Drupal\views\Plugin\Type\ArgumentValidatorPluginManager
;
use
Drupal\views\Plugin\Type\CachePluginManager
;
use
Drupal\views\Plugin\Type\LocalizationPluginManager
;
use
Drupal\views\Plugin\Type\PagerPluginManager
;
use
Drupal\views\Plugin\Type\QueryPluginManager
;
use
Drupal\views\Plugin\Type\RowPluginManager
;
use
Drupal\views\Plugin\Type\ExposedFormPluginManager
;
use
Drupal\views\Plugin\Type\HandlerPluginManager
;
use
Drupal\views\Plugin\Type\DisplayExtenderPluginManager
;
use
Drupal\views\Plugin\Type\WizardPluginManager
;
use
Drupal\views\Plugin\Type\ViewsPluginManager
;
/**
* Advertise the current views api version
...
...
@@ -1343,7 +1328,7 @@ function views_fetch_plugin_data($type = NULL, $plugin_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
=
views_get_p
lugin
_m
anager
(
$type
);
$manager
=
new
ViewsP
lugin
M
anager
(
$type
);
$definitions
=
$manager
->
getDefinitions
();
$plugins
=
array
();
...
...
@@ -1377,76 +1362,13 @@ function views_fetch_plugin_names($type, $key = NULL, $base = array()) {
function
views_get_plugin
(
$type
,
$plugin_id
,
$reset
=
FALSE
)
{
views_include
(
'handlers'
);
$manager
=
views_get_p
lugin
_m
anager
(
$type
);
$manager
=
new
ViewsP
lugin
M
anager
(
$type
);
$definition
=
$manager
->
getDefinition
(
$plugin_id
);
if
(
!
empty
(
$definition
))
{
return
_views_create_plugin
(
$type
,
$plugin_id
,
$definition
);
}
}
/**
* Returns the plugin manager used for a certain plugin type.
*
* @param string $type
* The plugin type to use.
*
* @param PluginManagerInterface
*/
function
views_get_plugin_manager
(
$type
)
{
switch
(
$type
)
{
case
'display'
:
$manager
=
new
DisplayPluginManager
();
break
;
case
'style'
:
$manager
=
new
StylePluginManager
();
break
;
case
'row'
:
$manager
=
new
RowPluginManager
();
break
;
case
'argument_default'
:
$manager
=
new
ArgumentDefaultPluginManager
();
break
;
case
'argument_validator'
:
$manager
=
new
ArgumentValidatorPluginManager
();
break
;
case
'access'
:
$manager
=
new
AccessPluginManager
();
break
;
case
'query'
:
$manager
=
new
QueryPluginManager
();
break
;
case
'cache'
:
$manager
=
new
CachePluginManager
();
break
;
// @todo: find out whether to use underscores or spaces.
case
'exposed_form'
:
$manager
=
new
ExposedFormPluginManager
();
break
;
case
'pager'
:
$manager
=
new
PagerPluginManager
();
break
;
case
'localization'
:
$manager
=
new
LocalizationPluginManager
();
break
;
case
'display_extender'
:
$manager
=
new
DisplayExtenderPluginManager
();
break
;
case
'wizard'
:
$manager
=
new
WizardPluginManager
();
break
;
case
'field'
:
case
'filter'
:
case
'argument'
:
case
'area'
:
case
'sort'
:
case
'relationship'
:
$manager
=
new
HandlerPluginManager
(
$type
);
break
;
}
return
$manager
;
}
/**
* Load the current enabled localization plugin.
*
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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