/** * {@inheritdoc} */ public function getIdentityTypes() { $config = $this->configFactory->get('rng.settings'); $identity_types = $config->get('identity_types'); $allowed_identity_types = is_array($identity_types) ? $identity_types : []; $available_identity_types = $this->identityChannelManager->getIdentityTypes(); return array_intersect($allowed_identity_types, $available_identity_types); }
/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $form = parent::buildForm($form, $form_state); $config = $this->config('rng.settings'); $identity_types = $config->get('identity_types'); $identity_types = is_array($identity_types) ? $identity_types : []; $form['contactables'] = ['#type' => 'details', '#title' => $this->t('Identity types'), '#description' => $this->t('Enable identity types who can register for events.'), '#open' => TRUE, '#tree' => TRUE]; foreach ($this->identityChannelManager->getIdentityTypes() as $identity_type) { $channels = $this->identityChannelManager->getChannelsForIdentityType($identity_type); $channels_string = []; foreach ($channels as $channel) { $entity_type = $this->entityManager->getDefinition($channel); $channels_string[] = $entity_type->getLabel(); } $entity_type = $this->entityManager->getDefinition($identity_type); $form['contactables'][$identity_type] = ['#type' => 'checkbox', '#title' => $this->t('@label (@provider)', ['@label' => $entity_type->getLabel(), '@provider' => $entity_type->getProvider()]), '#description' => $this->t('Supported channels: @channels', ['@channels' => implode(', ', $channels_string)]), '#default_value' => in_array($identity_type, $identity_types)]; } return $form; }