You are here

public function ScheduledUpdateAddController::add in Scheduled Updates 8

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

Parameters

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

Return value

array A render array for a list of the scheduled_update 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.

1 string reference to 'ScheduledUpdateAddController::add'
scheduled_updates.routing.yml in ./scheduled_updates.routing.yml
scheduled_updates.routing.yml

File

src/Controller/ScheduledUpdateAddController.php, line 70
Contains Drupal\scheduled_updates\Controller\ScheduledUpdateAddController.

Class

ScheduledUpdateAddController
Class ScheduledUpdateAddController.

Namespace

Drupal\scheduled_updates\Controller

Code

public function add(Request $request) {
  $types = $this
    ->getIndependentTypes();
  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' => 'Scheduled update',
        '@link' => Link::fromTextAndUrl($this
          ->t('Go to the type creation page'), Url::fromRoute('entity.scheduled_update_type.add_form')),
      ]),
    );
  }
  return array(
    '#theme' => 'scheduled_update_content_add_list',
    '#content' => $types,
  );
}