OpignoGroupMembershipStatus.php in Opigno Learning path 3.x
File
src/Plugin/views/filter/OpignoGroupMembershipStatus.php
View source
<?php
namespace Drupal\opigno_learning_path\Plugin\views\filter;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\filter\InOperator;
use Drupal\views\ViewExecutable;
use Drupal\views\Views;
class OpignoGroupMembershipStatus extends InOperator {
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
$this->valueTitle = t('Group Membership Status');
$this->tableAlias = 'opigno_learning_path_group_user_status';
$this->realField = 'status';
}
public function getValueOptions() {
if (isset($this->valueOptions)) {
return $this->valueOptions;
}
return $this->valueOptions = [
1 => $this
->t('Active'),
2 => $this
->t('Pending'),
3 => $this
->t('Blocked'),
];
}
public function query() {
parent::query();
$join = Views::pluginManager('join')
->createInstance('standard', [
'table' => 'opigno_learning_path_group_user_status',
'field' => 'mid',
'left_table' => 'group_content_field_data',
'left_field' => 'id',
'operator' => '=',
]);
$this->query
->addRelationship('opigno_learning_path_group_user_status', $join, 'group_content');
}
}