You are here

public function EntityTypeRoleAccessProvider::submitOperationConfigForm in Role Access Control 8.2

File

src/Plugin/adva/AccessProvider/EntityTypeRoleAccessProvider.php, line 91

Class

EntityTypeRoleAccessProvider
Provides pre role access to entities based upon type and bundle.

Namespace

Drupal\rac\Plugin\adva\AccessProvider

Code

public function submitOperationConfigForm(array $form, FormStateInterface $form_state) {
  parent::submitOperationConfigForm($form, $form_state);
  $new_config = $form_state
    ->getValues();
  if (isset($new_config['roles'])) {
    $new_config['roles'] = array_filter($new_config['roles']);
  }
  if (!isset($form['#entity_op']) || !isset($form['#entity_op_type'])) {
    return;
  }
  $op = $form['#entity_op'];
  $op_type = $form['#entity_op_type'];
  switch ($op_type) {
    case EntityTypeAccessProvider::ENTITY_TYPE_OP:
      $this->configuration['operations'][$op] = $new_config;
      break;
    case EntityTypeAccessProvider::ENTITY_DEFAULT_OP:
      $this->configuration['default']['operations'][$op] = $new_config;
      break;
    case EntityTypeAccessProvider::ENTITY_BUNDLE_OP:
      if (isset($form['#entity_bundle'])) {
        $bundle = $form['#entity_bundle'];
        $this->configuration['bundles']['override'][$bundle]['operations'][$op] = $new_config;
      }
      break;
  }
}