public function ConnectionAddController::add in RedHen CRM 8
Displays add links for available bundles/types for redhen_connection.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The current request object.
Return value
array A render array for a list of the redhen_connection bundles/types that can be added or if there is only one type/bundle defined for the site, the function returns the add page for that bundle/type.
File
- modules/
redhen_connection/ src/ Controller/ ConnectionAddController.php, line 51
Class
- ConnectionAddController
- Class ConnectionAddController.
Namespace
Drupal\redhen_connection\ControllerCode
public function add(Request $request) {
$entity = redhen_connection_get_connection_entity_from_route();
$types = $this->typeStorage
->loadMultiple();
foreach ($types as $key => $redhen_connection_type) {
$connection = $redhen_connection_type
->getEndpointEntityTypes($entity
->getEntityTypeId(), $entity
->getType());
if (empty($connection)) {
unset($types[$key]);
}
}
if ($types && count($types) == 1) {
$type = reset($types);
return $this
->addForm($request, $type, $entity);
}
if (count($types) === 0) {
return [
'#markup' => $this
->t('You have not created any %bundle types yet. @link to add a new type.', [
'%bundle' => 'Connection',
'@link' => Link::createFromRoute($this
->t('Go to the type creation page'), 'entity.redhen_connection_type.add_form'),
]),
];
}
return [
'#theme' => 'redhen_connection_content_add_list',
'#content' => $types,
'#entity' => $entity,
];
}