public function VkxpTokenSettingsForm::buildForm in VK CrossPoster 8
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides ConfigFormBase::buildForm
File
- src/
Form/ VkxpTokenSettingsForm.php, line 29 - Contains \Drupal\vkxp\Form\vkxpSettingsForm.
Class
Namespace
Drupal\vkxp\FormCode
public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL) {
$config = $this
->config('vkxp.token_settings');
$form['vkxp_access_token'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Write a token from VK'),
'#default_value' => $config
->get('vkxp_access_token'),
);
// FIRST STEP.
// Getting authorize code from VK.
$params = array();
//@TODO add app_id after main config form would be finished.
//$params['client_id'] = variable_get('vkxp_app_id');
$params['scope'] = VKXP_AUTHORIZE_SCOPE;
$params['redirect_uri'] = VKXP_ACCESS_TOKEN_REDIRECT_URI;
$params['response_type'] = VKXP_AUTHORIZE_RESPONSE_TYPE;
$url = Url::fromUri(VKXP_AUTHORIZE_URI, array(
'query' => $params,
'target' => '_blank',
));
$external_link = \Drupal::l(t('Get code'), $url);
$form['link'] = array(
'#markup' => $external_link,
);
return parent::buildForm($form, $form_state);
}