modules/acm_sku/src/Controller/SKUController.php
public function addPage() {
    $build = [
      '#theme' => 'sku_add_list',
      '#cache' => [
        'tags' => $this->entityManager()->getDefinition('acm_sku_type')->getListCacheTags(),
      ],
    ];

    $content = [];

    foreach ($this->entityManager()->getStorage('acm_sku_type')->loadMultiple() as $type) {
      $content[$type->id()] = $type;
    }

    // Bypass the sku/add listing if only one content type is available.
    if (count($content) == 1) {
      $type = array_shift($content);
      return $this->redirect('acm_sku.sku_add', ['acm_sku_type' => $type->id()]);
    }

    $build['#content'] = $content;

    return $build;
  }
public function addPage() {
    $build = [
      '#theme' => 'sku_add_list',
      '#cache' => [
        'tags' => $this->entityManager()->getDefinition('acm_sku_type')->getListCacheTags(),
      ],
    ];

    $content = [];

    foreach ($this->entityManager()->getStorage('acm_sku_type')->loadMultiple() as $type) {
      $content[$type->id()] = $type;
    }

    // Bypass the sku/add listing if only one content type is available.
    if (count($content) == 1) {
      $type = array_shift($content);
      return $this->redirect('acm_sku.sku_add', ['acm_sku_type' => $type->id()]);
    }

    $build['#content'] = $content;

    return $build;
  }
public function addPage ( ) { $ build = [ '#theme' => 'sku_add_list' , '#cache' => [ 'tags' => $ this -> entityManager ( ) -> getDefinition ( 'acm_sku_type' ) -> getListCacheTags ( ) , ] , ] ; $ content = [ ] ; foreach ( $ this -> entityManager ( ) -> getStorage ( 'acm_sku_type' ) -> loadMultiple ( ) as $ type ) { $ content [ $ type -> id ( ) ] = $ type ; } // Bypass the sku/add listing if only one content type is available. if ( count ( $ content ) == 1 ) { $ type = array_shift ( $ content ) ; return $ this -> redirect ( 'acm_sku.sku_add' , [ 'acm_sku_type' => $ type -> id ( ) ] ) ; } $ build [ '#content' ] = $ content ; return $ build ; }
Displays add SKU links for available SKU types.

Redirects to /admin/commerce/sku/add/[type] if only one content type is
available.

@return array|\Symfony\Component\HttpFoundation\RedirectResponse
A render array for a list of the SKU types that can be added; however,
if there is only one SKU type defined for the site, the function
will return a RedirectResponse to the SKU add page for that one SKU
type.
Displays add SKU links for available SKU types .