public function SiteSettingEntityAddController::add in Site Settings and Labels 8
Displays add links for available bundles/types.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The current request object.
Return value
array A render array for a list of the site_setting_entity bundles/types that can be added or if there is only one type/bunlde defined for the site, the function returns the add page for that bundle/type.
File
- src/
Controller/ SiteSettingEntityAddController.php, line 65
Class
- SiteSettingEntityAddController
- Class SiteSettingEntityAddController.
Namespace
Drupal\site_settings\ControllerCode
public function add(Request $request) {
$types = $this->typeStorage
->loadMultiple();
if ($types && count($types) == 1) {
$type = reset($types);
return $this
->addForm($type, $request);
}
if (count($types) === 0) {
return [
'#markup' => $this
->t('You have not created any %bundle types yet. @link to add a new type.', [
'%bundle' => 'Site Setting',
'@link' => Link::fromTextAndUrl($this
->t('Go to the type creation page'), Url::fromRoute('entity.site_setting_entity_type.add_form'))
->toString(),
]),
];
}
return [
'#theme' => 'site_setting_entity_content_add_list',
'#content' => $types,
];
}