Skip to content
Snippets Groups Projects
Commit 794a34ec authored by Lily Yan's avatar Lily Yan
Browse files

ISTWCMS-6737 Add default moderation state filter

parent 1d9a4600
No related branches found
No related tags found
1 merge request!33ISTWCMS-6737 Add default moderation state filter
...@@ -103,6 +103,23 @@ class ContentListBlock extends BlockBase implements ContainerFactoryPluginInterf ...@@ -103,6 +103,23 @@ class ContentListBlock extends BlockBase implements ContainerFactoryPluginInterf
$view->removeHandler($view->current_display, 'filter', 'type'); $view->removeHandler($view->current_display, 'filter', 'type');
} }
// Process Default moderation state filter field.
if (isset($this->configuration['moderation_state'])) {
// Get moderation state.
$state = $this->configuration['moderation_state'];
// Get current handler with old value.
$moderation_state = $view->getHandler($display_id, 'filter', 'current_state_views_filter');
// Set moderation_state configuration value.
$moderation_state['value'] = [$state => $state];
// Set handler with new value.
$view->setHandler($display_id, 'filter', 'current_state_views_filter', $moderation_state);
}
// Check if we have an author restriction, if so add to arguments and // Check if we have an author restriction, if so add to arguments and
// remove from exposed filters. // remove from exposed filters.
if (isset($this->configuration['display_my_content']) && $this->configuration['display_my_content']) { if (isset($this->configuration['display_my_content']) && $this->configuration['display_my_content']) {
...@@ -209,6 +226,20 @@ class ContentListBlock extends BlockBase implements ContainerFactoryPluginInterf ...@@ -209,6 +226,20 @@ class ContentListBlock extends BlockBase implements ContainerFactoryPluginInterf
'#default_value' => isset($this->configuration['content_type']) ? $this->configuration['content_type'] : 'all', '#default_value' => isset($this->configuration['content_type']) ? $this->configuration['content_type'] : 'all',
]; ];
// Set the content type form element.
$form['filters']['moderation_state'] = [
'#type' => 'select',
'#title' => $this->t('Default moderation state filter'),
'#options' => [
'All' => $this->t('- Any -'),
'uw_workflow-uw_wf_archived' => $this->t('Archived'),
'uw_workflow-draft' => $this->t('Draft'),
'uw_workflow-uw_wf_needs_review' => $this->t('Needs Review'),
'uw_workflow-published' => $this->t('Published'),
],
'#default_value' => isset($this->configuration['moderation_state']) ? $this->configuration['moderation_state'] : 'All',
];
// Set the display only my content form element. // Set the display only my content form element.
$form['filters']['display_my_content'] = [ $form['filters']['display_my_content'] = [
'#type' => 'select', '#type' => 'select',
...@@ -260,6 +291,9 @@ class ContentListBlock extends BlockBase implements ContainerFactoryPluginInterf ...@@ -260,6 +291,9 @@ class ContentListBlock extends BlockBase implements ContainerFactoryPluginInterf
// Set the config for content type. // Set the config for content type.
$this->configuration['content_type'] = $values['filters']['content_type']; $this->configuration['content_type'] = $values['filters']['content_type'];
// Set the config for moderation state.
$this->configuration['moderation_state'] = $values['filters']['moderation_state'];
// Set the config for displaying only my content. // Set the config for displaying only my content.
$this->configuration['display_my_content'] = $values['filters']['display_my_content']; $this->configuration['display_my_content'] = $values['filters']['display_my_content'];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment