protected function ZoneSelectionForm::buildZoneSelectSection in CloudFlare 8
Builds zone selection section for inclusion in the settings form.
Return value
array Form Api render array with selection section.
1 call to ZoneSelectionForm::buildZoneSelectSection()
- ZoneSelectionForm::buildForm in src/
Form/ ZoneSelectionForm.php - Form constructor.
File
- src/
Form/ ZoneSelectionForm.php, line 147
Class
- ZoneSelectionForm
- Class ZoneSelectionForm.
Namespace
Drupal\cloudflare\FormCode
protected function buildZoneSelectSection() {
$section = [];
$section['zone_selection_fieldset'] = [
'#type' => 'fieldset',
'#weight' => 0,
];
if (!$this->hasMultipleZones && $this->hasValidCredentials) {
// It is possible to authenticate with the API without having configured a
// domain in the CloudFlare console. This prevents a fatal error where
// zones[0]->getZoneId() is called on a NULL reference.
if (empty($this->zones)) {
$add_site_link = Link::fromTextAndUrl($this
->t('add a site'), Url::fromUri('https://www.cloudflare.com/a/setup'));
$section['zone_selection_fieldset']['zone_selection'] = [
'#markup' => $this
->t('<p>Your CloudFlare account does not have any zones configured. Verify your API details or !add_site_link via the console.</p>', [
'!add_site_link' => $add_site_link
->toString(),
]),
];
return $section;
}
$zone_id = $this->zones[0]
->getZoneId();
$this->config
->set('zone_id', $zone_id)
->save();
$section['zone_selection_fieldset']['zone_selection'] = [
'#markup' => $this
->t('<p>Your CloudFlare account has a single zone which has been automatically selected for you. Simply click "Finish" to save your settings.</p>'),
];
return $section;
}
$listing = $this
->buildZoneListing();
$section['zone_selection_fieldset']['zone_selection'] = $listing;
return $section;
}