You are here

public function LogAddController::add in Log entity 8

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

Parameters

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

Return value

array A render array for a list of the log 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/LogAddController.php, line 47

Class

LogAddController
Class LogAddController.

Namespace

Drupal\log\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 array(
      '#markup' => $this
        ->t('You have not created any %bundle types yet. @link to add a new type.', [
        '%bundle' => 'Log',
        '@link' => $this
          ->l($this
          ->t('Go to the type creation page'), Url::fromRoute('entity.log_type.add_form')),
      ]),
    );
  }
  return array(
    '#theme' => 'log_content_add_list',
    '#content' => $types,
  );
}