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
301
Merge Requests
301
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
e2bb2d64
Commit
e2bb2d64
authored
Oct 16, 2013
by
catch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2096787
by damiankloip, derhasi: Clean up Views area plugins.
parent
15acad2d
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
107 additions
and
64 deletions
+107
-64
core/modules/views/lib/Drupal/views/Plugin/views/HandlerBase.php
...dules/views/lib/Drupal/views/Plugin/views/HandlerBase.php
+13
-15
core/modules/views/lib/Drupal/views/Plugin/views/area/AreaPluginBase.php
...ews/lib/Drupal/views/Plugin/views/area/AreaPluginBase.php
+12
-16
core/modules/views/lib/Drupal/views/Plugin/views/area/Broken.php
...dules/views/lib/Drupal/views/Plugin/views/area/Broken.php
+19
-8
core/modules/views/lib/Drupal/views/Plugin/views/area/Entity.php
...dules/views/lib/Drupal/views/Plugin/views/area/Entity.php
+1
-2
core/modules/views/lib/Drupal/views/Plugin/views/area/HTTPStatusCode.php
...ews/lib/Drupal/views/Plugin/views/area/HTTPStatusCode.php
+0
-1
core/modules/views/lib/Drupal/views/Plugin/views/area/Result.php
...dules/views/lib/Drupal/views/Plugin/views/area/Result.php
+7
-2
core/modules/views/lib/Drupal/views/Plugin/views/area/Text.php
...modules/views/lib/Drupal/views/Plugin/views/area/Text.php
+6
-5
core/modules/views/lib/Drupal/views/Plugin/views/area/TextCustom.php
...s/views/lib/Drupal/views/Plugin/views/area/TextCustom.php
+1
-3
core/modules/views/lib/Drupal/views/Plugin/views/area/Title.php
...odules/views/lib/Drupal/views/Plugin/views/area/Title.php
+4
-6
core/modules/views/lib/Drupal/views/Plugin/views/area/View.php
...modules/views/lib/Drupal/views/Plugin/views/area/View.php
+44
-6
No files found.
core/modules/views/lib/Drupal/views/Plugin/views/HandlerBase.php
View file @
e2bb2d64
...
...
@@ -273,11 +273,6 @@ protected function caseTransform($string, $option) {
}
}
/**
* Validate the options form.
*/
public
function
validateOptionsForm
(
&
$form
,
&
$form_state
)
{
}
/**
* Build the options form.
*/
...
...
@@ -322,12 +317,6 @@ public function buildOptionsForm(&$form, &$form_state) {
\
Drupal
::
moduleHandler
()
->
alter
(
'views_handler_options'
,
$this
->
options
,
$this
->
view
);
}
/**
* Perform any necessary changes to the form values prior to storage.
* There is no need for this function to actually store the data.
*/
public
function
submitOptionsForm
(
&
$form
,
&
$form_state
)
{
}
/**
* Provides the handler some groupby.
*/
...
...
@@ -493,7 +482,14 @@ public function access() {
* This gives all the handlers some time to set up before any handler has
* been fully run.
*/
public
function
preQuery
()
{
}
public
function
preQuery
()
{
}
/**
* Don't run a query by default.
*/
public
function
query
()
{
}
/**
* Run after the view is executed, before the result is cached.
...
...
@@ -556,7 +552,7 @@ public function ensureMyTable() {
}
/**
* Provide text for the administrative summary
* Provide text for the administrative summary
.
*/
public
function
adminSummary
()
{
}
...
...
@@ -629,10 +625,12 @@ public function getJoin() {
public
function
validate
()
{
return
array
();
}
/**
* Determine if the handler is considered 'broken', meaning it's a
* Determine
s
if the handler is considered 'broken', meaning it's a
* a placeholder used when a handler can't be found.
*/
public
function
broken
()
{
}
public
function
broken
()
{
return
FALSE
;
}
/**
* Creates cross-database SQL date formatting.
...
...
core/modules/views/lib/Drupal/views/Plugin/views/area/AreaPluginBase.php
View file @
e2bb2d64
...
...
@@ -9,7 +9,6 @@
use
Drupal\views\ViewExecutable
;
use
Drupal\views\Plugin\views\display\DisplayPluginBase
;
use
Drupal\views\Plugin\views\PluginBase
;
use
Drupal\views\Plugin\views\HandlerBase
;
/**
...
...
@@ -47,6 +46,16 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
}
}
/**
* {@inheritdoc}
*/
public
function
usesGroupBy
()
{
return
FALSE
;
}
/**
* {@inheritdoc}
*/
protected
function
defineOptions
()
{
$options
=
parent
::
defineOptions
();
...
...
@@ -59,15 +68,14 @@ protected function defineOptions() {
}
/**
*
Provide extra data to the administration form
*
{@inheritdoc}
*/
public
function
adminSummary
()
{
return
$this
->
adminLabel
();
}
/**
* Default options form that provides the label widget that all fields
* should have.
* {@inheritdoc}
*/
public
function
buildOptionsForm
(
&
$form
,
&
$form_state
)
{
parent
::
buildOptionsForm
(
$form
,
$form_state
);
...
...
@@ -81,11 +89,6 @@ public function buildOptionsForm(&$form, &$form_state) {
}
}
/**
* Don't run a query
*/
public
function
query
()
{
}
/**
* Performs any operations needed before full rendering.
*
...
...
@@ -119,13 +122,6 @@ public function isEmpty() {
return
empty
(
$this
->
options
[
'empty'
]);
}
/**
* Area handlers shouldn't have groupby.
*/
public
function
usesGroupBy
()
{
return
FALSE
;
}
}
/**
...
...
core/modules/views/lib/Drupal/views/Plugin/views/area/Broken.php
View file @
e2bb2d64
...
...
@@ -7,9 +7,6 @@
namespace
Drupal\views\Plugin\views\area
;
use
Drupal\Component\Annotation\PluginID
;
use
Drupal\views\ViewExecutable
;
/**
* A special handler to take the place of missing or broken handlers.
*
...
...
@@ -19,6 +16,9 @@
*/
class
Broken
extends
AreaPluginBase
{
/**
* {@inheritdoc}
*/
public
function
adminLabel
(
$short
=
FALSE
)
{
$args
=
array
(
'@module'
=>
$this
->
definition
[
'original_configuration'
][
'provider'
],
...
...
@@ -26,11 +26,22 @@ public function adminLabel($short = FALSE) {
return
$this
->
isOptional
()
?
t
(
'Optional handler is missing (Module: @module) …'
,
$args
)
:
t
(
'Broken/missing handler (Module: @module) …'
,
$args
);
}
public
function
defineOptions
()
{
return
array
();
}
public
function
ensureMyTable
()
{
/* No table to ensure! */
}
public
function
query
(
$group_by
=
FALSE
)
{
/* No query to run */
}
/**
* Implements \Drupal\views\Plugin\views\area\AreaPluginBase::render().
* {@inheritdoc}
*/
public
function
defineOptions
()
{
return
array
();
}
/**
* {@inheritdoc}
*/
public
function
ensureMyTable
()
{
// No table to ensure.
}
/**
* {@inheritdoc}
*/
public
function
render
(
$empty
=
FALSE
)
{
// Simply render nothing by returning an empty render array.
...
...
@@ -75,7 +86,7 @@ public function buildOptionsForm(&$form, &$form_state) {
}
/**
*
Determine if the handler is considered 'broken'
*
{@inheritdoc}
*/
public
function
broken
()
{
return
TRUE
;
...
...
core/modules/views/lib/Drupal/views/Plugin/views/area/Entity.php
View file @
e2bb2d64
...
...
@@ -9,7 +9,6 @@
use
Drupal\views\Plugin\views\display\DisplayPluginBase
;
use
Drupal\views\ViewExecutable
;
use
Drupal\Component\Annotation\PluginID
;
/**
* Provides an area handler which renders an entity in a certain view mode.
...
...
@@ -89,7 +88,7 @@ protected function buildViewModeOptions() {
}
/**
*
Overrides \Drupal\views\Plugin\views\area\AreaPluginBase::render().
*
{@inheritdoc}
*/
public
function
render
(
$empty
=
FALSE
)
{
if
(
!
$empty
||
!
empty
(
$this
->
options
[
'empty'
]))
{
...
...
core/modules/views/lib/Drupal/views/Plugin/views/area/HTTPStatusCode.php
View file @
e2bb2d64
...
...
@@ -8,7 +8,6 @@
namespace
Drupal\views\Plugin\views\area
;
use
Symfony\Component\HttpFoundation\Response
;
use
Drupal\Component\Annotation\PluginID
;
/**
* Alter the HTTP response status code used by the view.
...
...
core/modules/views/lib/Drupal/views/Plugin/views/area/Result.php
View file @
e2bb2d64
...
...
@@ -7,7 +7,6 @@
namespace
Drupal\views\Plugin\views\area
;
use
Drupal\Component\Annotation\PluginID
;
use
Drupal\Component\Utility\String
;
use
Drupal\Component\Utility\Xss
;
use
Drupal\views\Plugin\views\style\DefaultSummary
;
...
...
@@ -21,6 +20,9 @@
*/
class
Result
extends
AreaPluginBase
{
/**
* {@inheritdoc}
*/
protected
function
defineOptions
()
{
$options
=
parent
::
defineOptions
();
...
...
@@ -32,6 +34,9 @@ protected function defineOptions() {
return
$options
;
}
/**
* {@inheritdoc}
*/
public
function
buildOptionsForm
(
&
$form
,
&
$form_state
)
{
parent
::
buildOptionsForm
(
$form
,
$form_state
);
$item_list
=
array
(
...
...
@@ -67,7 +72,7 @@ public function query() {
}
/**
*
Implements \Drupal\views\Plugin\views\area\AreaPluginBase::render().
*
{@inheritdoc}
*/
public
function
render
(
$empty
=
FALSE
)
{
// Must have options and does not work on summaries.
...
...
core/modules/views/lib/Drupal/views/Plugin/views/area/Text.php
View file @
e2bb2d64
...
...
@@ -7,8 +7,6 @@
namespace
Drupal\views\Plugin\views\area
;
use
Drupal\Component\Annotation\PluginID
;
/**
* Views area text handler.
*
...
...
@@ -19,7 +17,7 @@
class
Text
extends
TokenizeAreaPluginBase
{
/**
*
Overrides \Drupal\views\Plugin\views\area\TokenizeAreaPluginBase::defineOptions().
*
{@inheritdoc}
*/
protected
function
defineOptions
()
{
$options
=
parent
::
defineOptions
();
...
...
@@ -29,7 +27,7 @@ protected function defineOptions() {
}
/**
*
Overrides \Drupal\views\Plugin\views\area\TokenizeAreaPluginBase::buildOptionsForm().
*
{@inheritdoc}
*/
public
function
buildOptionsForm
(
&
$form
,
&
$form_state
)
{
parent
::
buildOptionsForm
(
$form
,
$form_state
);
...
...
@@ -44,6 +42,9 @@ public function buildOptionsForm(&$form, &$form_state) {
);
}
/**
* {@inheritdoc}
*/
public
function
submitOptionsForm
(
&
$form
,
&
$form_state
)
{
$form_state
[
'values'
][
'options'
][
'format'
]
=
$form_state
[
'values'
][
'options'
][
'content'
][
'format'
];
$form_state
[
'values'
][
'options'
][
'content'
]
=
$form_state
[
'values'
][
'options'
][
'content'
][
'value'
];
...
...
@@ -51,7 +52,7 @@ public function submitOptionsForm(&$form, &$form_state) {
}
/**
*
Implements \Drupal\views\Plugin\views\area\AreaPluginBase::render().
*
{@inheritdoc}
*/
public
function
render
(
$empty
=
FALSE
)
{
$format
=
isset
(
$this
->
options
[
'format'
])
?
$this
->
options
[
'format'
]
:
filter_default_format
();
...
...
core/modules/views/lib/Drupal/views/Plugin/views/area/TextCustom.php
View file @
e2bb2d64
...
...
@@ -7,8 +7,6 @@
namespace
Drupal\views\Plugin\views\area
;
use
Drupal\Component\Annotation\PluginID
;
/**
* Views area text handler.
*
...
...
@@ -42,7 +40,7 @@ public function buildOptionsForm(&$form, &$form_state) {
}
/**
*
Implements \Drupal\views\Plugin\views\area\AreaPluginBase::render().
*
{@inheritdoc}
*/
public
function
render
(
$empty
=
FALSE
)
{
if
(
!
$empty
||
!
empty
(
$this
->
options
[
'empty'
]))
{
...
...
core/modules/views/lib/Drupal/views/Plugin/views/area/Title.php
View file @
e2bb2d64
...
...
@@ -7,8 +7,6 @@
namespace
Drupal\views\Plugin\views\area
;
use
Drupal\Component\Annotation\PluginID
;
/**
* Views area title override handler.
*
...
...
@@ -19,7 +17,7 @@
class
Title
extends
AreaPluginBase
{
/**
*
Overrides Drupal\views\Plugin\views\AreaPluginBase::defineOptions().
*
{@inheritdoc}
*/
protected
function
defineOptions
()
{
$options
=
parent
::
defineOptions
();
...
...
@@ -28,7 +26,7 @@ protected function defineOptions() {
}
/**
*
Overrides Drupal\views\Plugin\views\AreaPluginBase::buildOptionsForm().
*
{@inheritdoc}
*/
public
function
buildOptionsForm
(
&
$form
,
&
$form_state
)
{
parent
::
buildOptionsForm
(
$form
,
$form_state
);
...
...
@@ -45,7 +43,7 @@ public function buildOptionsForm(&$form, &$form_state) {
}
/**
*
Overrides Drupal\views\Plugin\views\AreaPluginBase::preRender().
*
{@inheritdoc}
*/
public
function
preRender
(
array
$results
)
{
parent
::
preRender
(
$results
);
...
...
@@ -58,7 +56,7 @@ public function preRender(array $results) {
}
/**
*
Implements \Drupal\views\Plugin\views\area\AreaPluginBase::render().
*
{@inheritdoc}
*/
public
function
render
(
$empty
=
FALSE
)
{
// Do nothing for this handler by returning an empty render array.
...
...
core/modules/views/lib/Drupal/views/Plugin/views/area/View.php
View file @
e2bb2d64
...
...
@@ -2,12 +2,13 @@
/**
* @file
*
Definition of
Drupal\views\Plugin\views\area\View.
*
Contains \
Drupal\views\Plugin\views\area\View.
*/
namespace
Drupal\views\Plugin\views\area
;
use
Drupal\Component\Annotation\PluginID
;
use
Drupal\Core\Entity\EntityStorageControllerInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
* Views area handlers. Insert a view inside of an area.
...
...
@@ -25,6 +26,43 @@ class View extends AreaPluginBase {
*/
protected
$isEmpty
;
/**
* The view storage controller.
*
* @var \Drupal\Core\Entity\EntityStorageControllerInterface
*/
protected
$viewStorage
;
/**
* Constructs a View object.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param array $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Entity\EntityStorageControllerInterface $view_storage
* The view storage controller.
*/
public
function
__construct
(
array
$configuration
,
$plugin_id
,
array
$plugin_definition
,
EntityStorageControllerInterface
$view_storage
)
{
parent
::
__construct
(
$configuration
,
$plugin_id
,
$plugin_definition
);
$this
->
viewStorage
=
$view_storage
;
}
/**
* {@inheritdoc}
*/
public
static
function
create
(
ContainerInterface
$container
,
array
$configuration
,
$plugin_id
,
array
$plugin_definition
)
{
return
new
static
(
$configuration
,
$plugin_id
,
$plugin_definition
,
$container
->
get
(
'entity.manager'
)
->
getStorageController
(
'view'
)
);
}
/**
* {@inheritdoc}
*/
...
...
@@ -37,8 +75,7 @@ protected function defineOptions() {
}
/**
* Default options form that provides the label widget that all fields
* should have.
* {@inheritdoc}
*/
public
function
buildOptionsForm
(
&
$form
,
&
$form_state
)
{
parent
::
buildOptionsForm
(
$form
,
$form_state
);
...
...
@@ -64,13 +101,14 @@ public function buildOptionsForm(&$form, &$form_state) {
}
/**
*
Implements \Drupal\views\Plugin\views\area\AreaPluginBase::render().
*
{@inheritdoc}
*/
public
function
render
(
$empty
=
FALSE
)
{
if
(
!
empty
(
$this
->
options
[
'view_to_insert'
]))
{
list
(
$view_name
,
$display_id
)
=
explode
(
':'
,
$this
->
options
[
'view_to_insert'
]);
$view
=
views_get_view
(
$view_name
);
$view
=
$this
->
viewStorage
->
load
(
$view_name
);
if
(
empty
(
$view
)
||
!
$view
->
access
(
$display_id
))
{
return
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