You are here

public function Menu::getViewsJoin in Workbench Access 8

@TODO: Refactor

Overrides AccessControlHierarchyBase::getViewsJoin

File

src/Plugin/AccessControlHierarchy/Menu.php, line 209

Class

Menu
Defines a hierarchy based on a Menu.

Namespace

Drupal\workbench_access\Plugin\AccessControlHierarchy

Code

public function getViewsJoin($entity_type, $key, $alias = NULL) {
  if ($entity_type == 'user') {
    $configuration['menu'] = [
      'table' => 'section_association__user_id',
      'field' => 'user_id_target_id',
      'left_table' => 'users',
      'left_field' => $key,
      'operator' => '=',
      'table_alias' => 'section_association__user_id',
      'real_field' => 'entity_id',
    ];
    return $configuration;
  }
  else {
    $configuration['menu'] = [
      'table' => 'menu_tree',
      'field' => 'route_param_key',
      'left_table' => 'node',
      'left_field' => $key,
      'left_query' => "CONCAT('node=', {$alias}.{$key})",
      'operator' => '=',
      'table_alias' => 'menu_tree',
      'real_field' => 'id',
    ];
  }
  return $configuration;
}