public function ConfigPagesController::classInit in Config Pages 8
Same name and namespace in other branches
- 8.3 src/Controller/ConfigPagesController.php \Drupal\config_pages\Controller\ConfigPagesController::classInit()
- 8.2 src/Controller/ConfigPagesController.php \Drupal\config_pages\Controller\ConfigPagesController::classInit()
Presents the config page creation/edit form.
Parameters
\Drupal\config_pages\ConfigPagesTypeInterface $config_pages_type: The config page type to add.
Return value
array A form array as expected by drupal_render().
1 string reference to 'ConfigPagesController::classInit'
File
- src/
Controller/ ConfigPagesController.php, line 118
Class
Namespace
Drupal\config_pages\ControllerCode
public function classInit($config_pages_type = '') {
$typeEntity = ConfigPagesType::load($config_pages_type);
if (empty($typeEntity)) {
throw new NotFoundHttpException();
}
$contextData = $typeEntity
->getContextData();
$config_page_ids = $this->entityQuery
->get('config_pages')
->condition('type', $config_pages_type)
->condition('context', $contextData)
->execute();
if (!empty($config_page_ids)) {
$config_page_id = array_shift($config_page_ids);
$entityStorage = $this->entityTypeManager
->getStorage('config_pages');
$config_page = $entityStorage
->load($config_page_id);
}
else {
$config_page = $this->ConfigPagesStorage
->create([
'type' => $config_pages_type,
]);
}
return $this
->entityFormBuilder()
->getForm($config_page);
}