You are here

function EventTypeAccessDefaultsForm::actionRows in RNG - Events and Registrations 8

Same name and namespace in other branches
  1. 8.2 src/Form/EventTypeAccessDefaultsForm.php \Drupal\rng\Form\EventTypeAccessDefaultsForm::actionRows()
  2. 3.x src/Form/EventTypeAccessDefaultsForm.php \Drupal\rng\Form\EventTypeAccessDefaultsForm::actionRows()
1 call to EventTypeAccessDefaultsForm::actionRows()
EventTypeAccessDefaultsForm::buildForm in src/Form/EventTypeAccessDefaultsForm.php
Form constructor.

File

src/Form/EventTypeAccessDefaultsForm.php, line 250

Class

EventTypeAccessDefaultsForm
Form for event type access defaults.

Namespace

Drupal\rng\Form

Code

function actionRows($rule, array $operations, $scope_all, $supports_create) {
  $rowspan = count($rule
    ->getConditions());

  // Actions.
  if ($action = $rule
    ->getAction('registration_operations')) {
    $row = [];

    // Operations granted.
    $config = $action['configuration'];
    foreach ($operations as $op => $t) {
      $disabled = $op == 'create' && $supports_create != count($rule
        ->getConditions());
      if ($disabled) {
        $row[] = [
          '#plain_text' => $this
            ->t('N/A'),
          '#wrapper_attributes' => [
            'class' => [
              'checkbox',
            ],
          ],
        ];
      }
      else {
        $row[] = [
          '#type' => 'checkbox',
          '#title' => $this
            ->t('@operation', [
            '@operation' => $t,
          ]),
          '#title_display' => 'invisible',
          '#default_value' => !empty($config['operations'][$op]),
          '#parents' => [
            'actions',
            'operations',
            $rule
              ->getMachineName(),
            $op,
          ],
          '#wrapper_attributes' => [
            'class' => [
              'checkbox',
            ],
            'rowspan' => $rowspan,
          ],
        ];
      }
    }
    return $row;
  }
}