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
0a1b1dc9
Commit
0a1b1dc9
authored
Oct 12, 2012
by
damiankloip
Committed by
tim.plunkett
Oct 21, 2012
Browse files
Issue
#1810788
by damiankloip: Added enable and disable procedural wrappers.
parent
cc0a0cc1
Changes
3
Hide whitespace changes
Inline
Side-by-side
lib/Drupal/views/Tests/ModuleTest.php
View file @
0a1b1dc9
...
...
@@ -175,6 +175,23 @@ public function testLoadFunctions() {
$this
->
assertIdentical
(
$expected_opt_groups
,
views_get_views_as_options
(
FALSE
,
'all'
,
NULL
,
TRUE
),
'Expected option array for an option group returned.'
);
}
/**
* Tests view enable and disable procedural wrapper functions.
*/
function
testStatusFunctions
()
{
$view
=
views_get_view
(
'test_view_status'
)
->
storage
;
$this
->
assertFalse
(
$view
->
isEnabled
(),
'The view status is disabled.'
);
views_enable_view
(
$view
);
$this
->
assertTrue
(
$view
->
isEnabled
(),
'A view has been enabled.'
);
$this
->
assertEqual
(
$view
->
isEnabled
(),
views_view_is_enabled
(
$view
),
'views_view_is_enabled is correct.'
);
views_disable_view
(
$view
);
$this
->
assertFalse
(
$view
->
isEnabled
(),
'A view has been disabled.'
);
$this
->
assertEqual
(
!
$view
->
isEnabled
(),
views_view_is_disabled
(
$view
),
'views_view_is_disabled is correct.'
);
}
/**
* Helper to return an expected views option array.
*
...
...
tests/views_test_config/config/views.view.test_view_status.yml
0 → 100644
View file @
0a1b1dc9
base_table
:
views_test_data
name
:
test_view_status
description
:
'
'
tag
:
'
'
human_name
:
test_view_status
core
:
8.x
api_version
:
'
3.0'
display
:
default
:
display_plugin
:
default
id
:
default
display_title
:
Master
position
:
'
'
base_field
:
id
disabled
:
'
1'
module
:
views
views.module
View file @
0a1b1dc9
...
...
@@ -12,6 +12,7 @@
use
Drupal\Core\Database\Query\AlterableInterface
;
use
Drupal\views\ViewExecutable
;
use
Drupal\Component\Plugin\Exception\PluginException
;
use
Drupal\views\ViewStorage
;
/**
* Views API version string.
...
...
@@ -1633,29 +1634,49 @@ function views_get_views_as_options($views_only = FALSE, $filter = 'all', $exclu
/**
* Returns whether the view is enabled.
*
* @param Drupal\views\View
Executabl
e $view
* @param Drupal\views\View
Storag
e $view
* The view object to check.
*
* @return bool
* Returns TRUE if a view is enabled, FALSE otherwise.
*/
function
views_view_is_enabled
(
$view
)
{
function
views_view_is_enabled
(
ViewStorage
$view
)
{
return
$view
->
isEnabled
();
}
/**
* Returns whether the view is disabled.
*
* @param Drupal\views\View
Executabl
e $view
* @param Drupal\views\View
Storag
e $view
* The view object to check.
*
* @return bool
* Returns TRUE if a view is disabled, FALSE otherwise.
*/
function
views_view_is_disabled
(
$view
)
{
function
views_view_is_disabled
(
ViewStorage
$view
)
{
return
!
$view
->
isEnabled
();
}
/**
* Enables a view.
*
* @param Drupal\views\ViewStorage $view
* The ViewStorage object to disable.
*/
function
views_enable_view
(
ViewStorage
$view
)
{
$view
->
enable
();
}
/**
* Disables a view.
*
* @param Drupal\views\ViewStorage $view
* The ViewStorage object to disable.
*/
function
views_disable_view
(
ViewStorage
$view
)
{
$view
->
disable
();
}
/**
* Loads a view from configuration.
*
...
...
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