Skip to the content.

← Back to Awards Plugin

5.2.12 LevelsTable Policy Reference

Last Updated: December 4, 2025
Status: Complete
Plugin: Awards
Source: plugins/Awards/src/Policy/LevelsTablePolicy.php

Overview

The LevelsTablePolicy class provides table-level authorization for award level management within the Awards plugin. It manages hierarchical level data access, precedence operations, bulk operations, and administrative oversight through integration with the KMP RBAC system.

Class Definition

namespace Awards\Policy;

class LevelsTablePolicy extends BasePolicy

RBAC Integration Architecture

Permission-Based Authorization

BasePolicy Inheritance

The policy inherits standard table authorization methods:

Method Purpose
canIndex() Level listing with organizational scoping
canAdd() Level creation with administrative permission requirements
scopeIndex() Query scoping for branch-based access control

Custom Authorization Methods

scopeGridData()

Provides query scoping for Dataverse grid data endpoints, delegating to standard index authorization.

public function scopeGridData(KmpIdentityInterface $user, mixed $query): mixed

Parameters:

Returns: Scoped query with appropriate access restrictions

Purpose:

Table Operations Governance

Authorization is enforced for all table-level operations:

Operation Authorization Requirements
Query Authorization Permission validation for level listing and hierarchical data retrieval
Hierarchical Management Access control for precedence-based queries and level ordering
Structural Modifications Administrative permissions for bulk level operations
Grid Data Access Consistent authorization through scopeGridData()

Query Scoping

The policy implements query filtering:

Authorization Flow

sequenceDiagram
    participant Controller
    participant Authorization
    participant LevelsTablePolicy
    participant BasePolicy
    participant PermissionsLoader
    
    Controller->>Authorization: applyScope($query, 'gridData')
    Authorization->>LevelsTablePolicy: scopeGridData($user, $query)
    LevelsTablePolicy->>LevelsTablePolicy: scopeIndex($user, $query)
    LevelsTablePolicy->>BasePolicy: Apply branch scoping
    BasePolicy-->>LevelsTablePolicy: Scoped Query
    LevelsTablePolicy-->>Authorization: Scoped Query
    Authorization-->>Controller: Authorized Query

Usage Examples

Controller Integration

// Standard table authorization in LevelsController
public function index() {
    $this->Authorization->authorize($this->Levels, 'index');
    $levels = $this->paginate($this->Levels);
    $this->set(compact('levels'));
}

Grid Data Access

// Dataverse grid data with consistent scoping
public function gridData() {
    $query = $this->Levels->find()->order(['precedence' => 'ASC']);
    $scopedQuery = $this->Authorization->applyScope($query, 'gridData');
    // Return scoped data for grid display...
}

Hierarchical Management Services

// Level management with precedence ordering
$levelsQuery = $this->Levels->find()
    ->order(['precedence' => 'ASC']);
$authorizedQuery = $this->Authorization->applyScope($user, 'index', $levelsQuery);

Administrative Operations

// Administrative level creation
if ($this->Authorization->can($user, 'add', $this->Levels)) {
    // Bulk level creation with precedence validation...
}

Integration Points

Levels Controller Integration

RBAC System Integration

Awards Plugin Integration

Security Considerations

Access Control Security

Data Protection