Issue #3201393 by Lendude, dww, imalabya, dawehner, anmolgoyal74, Abhijith S: Filter glossary view by status
parent
6d0f2eb0f5
commit
7e922b6dd6
|
@ -307,6 +307,19 @@ display:
|
|||
empty: { }
|
||||
sorts: { }
|
||||
filters:
|
||||
status:
|
||||
expose:
|
||||
operator: ''
|
||||
operator_limit_selection: false
|
||||
operator_list: { }
|
||||
field: status
|
||||
group: 1
|
||||
id: status
|
||||
table: node_field_data
|
||||
value: '1'
|
||||
plugin_id: boolean
|
||||
entity_type: node
|
||||
entity_field: status
|
||||
langcode:
|
||||
id: langcode
|
||||
table: node_field_data
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* Post update functions for Node.
|
||||
*/
|
||||
|
||||
use Drupal\views\Entity\View;
|
||||
|
||||
/**
|
||||
* Implements hook_removed_post_updates().
|
||||
*/
|
||||
|
@ -14,3 +16,34 @@ function node_removed_post_updates() {
|
|||
'node_post_update_node_revision_views_data' => '9.0.0',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a published filter to the glossary View.
|
||||
*/
|
||||
function node_post_update_glossary_view_published() {
|
||||
if (\Drupal::moduleHandler()->moduleExists('views')) {
|
||||
$view = View::load('glossary');
|
||||
if (!$view) {
|
||||
return;
|
||||
}
|
||||
$display =& $view->getDisplay('default');
|
||||
if (!isset($display['display_options']['filters']['status'])) {
|
||||
$display['display_options']['filters']['status'] = [
|
||||
'expose' => [
|
||||
'operator' => '',
|
||||
'operator_limit_selection' => FALSE,
|
||||
'operator_list' => [],
|
||||
],
|
||||
'field' => 'status',
|
||||
'group' => 1,
|
||||
'id' => 'status',
|
||||
'table' => 'node_field_data',
|
||||
'value' => '1',
|
||||
'plugin_id' => 'boolean',
|
||||
'entity_type' => 'node',
|
||||
'entity_field' => 'status',
|
||||
];
|
||||
$view->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\views\Functional\Update;
|
||||
|
||||
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
|
||||
use Drupal\views\Entity\View;
|
||||
|
||||
/**
|
||||
* Tests that the status filter is added to the glossary view.
|
||||
*
|
||||
* @group Update
|
||||
*/
|
||||
class GlossaryStatusFilterTest extends UpdatePathTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setDatabaseDumpFiles() {
|
||||
$this->databaseDumpFiles = [
|
||||
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-9.0.0.filled.standard.php.gz',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the default glossary view.
|
||||
*/
|
||||
public function testGlossaryView() {
|
||||
$view = View::load('glossary');
|
||||
|
||||
$this->assertTrue(empty($view->getDisplay('default')['display_options']['filters']['status']));
|
||||
|
||||
$this->runUpdates();
|
||||
|
||||
$view = View::load('glossary');
|
||||
$this->assertNotEmpty($view->getDisplay('default')['display_options']['filters']['status']);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue