You are here

public function ContactAddController::add in RedHen CRM 8

Displays add links for available bundles/types for entity redhen_contact .

Parameters

\Symfony\Component\HttpFoundation\Request $request: The current request object.

Return value

array A render array for a list of the redhen_contact bundles/types that can be added or if there is only one bundle/type defined for the site, the function returns the add page for that bundle/type.

File

modules/redhen_contact/src/Controller/ContactAddController.php, line 48

Class

ContactAddController
Class ContactAddController.

Namespace

Drupal\redhen_contact\Controller

Code

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' => 'Contact',
        '@link' => Link::createFromRoute($this
          ->t('Go to the type creation page'), 'entity.redhen_contact_type.add_form'),
      ]),
    ];
  }
  return [
    '#theme' => 'redhen_contact_content_add_list',
    '#content' => $types,
  ];
}