original_string: protected function generateTypeList($entity_type, $bundle_type, $entity_add_form, $bundle_add_form, NodeInterface $node, $field) {
      $type_definition = $this->entityTypeManager->getDefinition($bundle_type);
  
      $build = [
        '#theme' => 'entity_add_list',
        '#bundles' => [],
        '#cache' => ['tags' => $type_definition->getListCacheTags()],
      ];
  
      $bundles = $this->entityTypeManager->getStorage($bundle_type)->loadMultiple();
      $access_control_handler = $this->entityTypeManager->getAccessControlHandler($entity_type);
  
      foreach (array_keys($bundles) as $bundle_id) {
        $bundle = $bundles[$bundle_id];
  
        // Skip bundles that don't have the specified field.
        $fields = $this->entityFieldManager->getFieldDefinitions($entity_type, $bundle_id);
        if (!isset($fields[$field])) {
          continue;
        }
  
        $build['#bundles'][$bundle_id] = [
          'label' => $bundle->label(),
          'description' => $bundle->getDescription(),
          'add_link' => Link::createFromRoute(
            $bundle->label(),
            $entity_add_form,
            [$bundle_type => $bundle->id()],
            ['query' => ["edit[$field][widget][0][target_id]" => $node->id()]]
          ),
        ];
      }
  
      // Filter out bundles the user can't create.
      foreach (array_keys($bundles) as $bundle_id) {
        $access = $access_control_handler->createAccess($bundle_id, NULL, [], TRUE);
        if (!$access->isAllowed()) {
          unset($build['#bundles'][$bundle_id]);
        }
        $this->renderer->addCacheableDependency($build, $access);
      }
  
      // Build the message shown when there are no bundles.
      $type_label = $type_definition->getLowercaseLabel();
      $link_text = $this->t('Add a new @entity_type.', ['@entity_type' => $type_label]);
      $build['#add_bundle_message'] = $this->t('There is no @entity_type yet. @add_link', [
        '@entity_type' => $type_label,
        '@add_link' => Link::createFromRoute($link_text, $bundle_add_form)->toString(),
      ]);
  
      return $build;
    }
code: protected function generateTypeList($entity_type, $bundle_type, $entity_add_form, $bundle_add_form, NodeInterface $node, $field) {
      $type_definition = $this->entityTypeManager->getDefinition($bundle_type);
  
      $build = [
        '#theme' => 'entity_add_list',
        '#bundles' => [],
        '#cache' => ['tags' => $type_definition->getListCacheTags()],
      ];
  
      $bundles = $this->entityTypeManager->getStorage($bundle_type)->loadMultiple();
      $access_control_handler = $this->entityTypeManager->getAccessControlHandler($entity_type);
  
      foreach (array_keys($bundles) as $bundle_id) {
        $bundle = $bundles[$bundle_id];
  
        // Skip bundles that don't have the specified field.
        $fields = $this->entityFieldManager->getFieldDefinitions($entity_type, $bundle_id);
        if (!isset($fields[$field])) {
          continue;
        }
  
        $build['#bundles'][$bundle_id] = [
          'label' => $bundle->label(),
          'description' => $bundle->getDescription(),
          'add_link' => Link::createFromRoute(
            $bundle->label(),
            $entity_add_form,
            [$bundle_type => $bundle->id()],
            ['query' => ["edit[$field][widget][0][target_id]" => $node->id()]]
          ),
        ];
      }
  
      // Filter out bundles the user can't create.
      foreach (array_keys($bundles) as $bundle_id) {
        $access = $access_control_handler->createAccess($bundle_id, NULL, [], TRUE);
        if (!$access->isAllowed()) {
          unset($build['#bundles'][$bundle_id]);
        }
        $this->renderer->addCacheableDependency($build, $access);
      }
  
      // Build the message shown when there are no bundles.
      $type_label = $type_definition->getLowercaseLabel();
      $link_text = $this->t('Add a new @entity_type.', ['@entity_type' => $type_label]);
      $build['#add_bundle_message'] = $this->t('There is no @entity_type yet. @add_link', [
        '@entity_type' => $type_label,
        '@add_link' => Link::createFromRoute($link_text, $bundle_add_form)->toString(),
      ]);
  
      return $build;
    }
code_tokens: protected function generateTypeList ( $ entity_type , $ bundle_type , $ entity_add_form , $ bundle_add_form , NodeInterface $ node , $ field ) { $ type_definition = $ this -> entityTypeManager -> getDefinition ( $ bundle_type ) ; $ build = [ '#theme' => 'entity_add_list' , '#bundles' => [ ] , '#cache' => [ 'tags' => $ type_definition -> getListCacheTags ( ) ] , ] ; $ bundles = $ this -> entityTypeManager -> getStorage ( $ bundle_type ) -> loadMultiple ( ) ; $ access_control_handler = $ this -> entityTypeManager -> getAccessControlHandler ( $ entity_type ) ; foreach ( array_keys ( $ bundles ) as $ bundle_id ) { $ bundle = $ bundles [ $ bundle_id ] ; // Skip bundles that don't have the specified field. $ fields = $ this -> entityFieldManager -> getFieldDefinitions ( $ entity_type , $ bundle_id ) ; if ( ! isset ( $ fields [ $ field ] ) ) { continue ; } $ build [ '#bundles' ] [ $ bundle_id ] = [ 'label' => $ bundle -> label ( ) , 'description' => $ bundle -> getDescription ( ) , 'add_link' => Link :: createFromRoute ( $ bundle -> label ( ) , $ entity_add_form , [ $ bundle_type => $ bundle -> id ( ) ] , [ 'query' => [ "edit[$field][widget][0][target_id]" => $ node -> id ( ) ] ] ) , ] ; } // Filter out bundles the user can't create. foreach ( array_keys ( $ bundles ) as $ bundle_id ) { $ access = $ access_control_handler -> createAccess ( $ bundle_id , NULL , [ ] , TRUE ) ; if ( ! $ access -> isAllowed ( ) ) { unset ( $ build [ '#bundles' ] [ $ bundle_id ] ) ; } $ this -> renderer -> addCacheableDependency ( $ build , $ access ) ; } // Build the message shown when there are no bundles. $ type_label = $ type_definition -> getLowercaseLabel ( ) ; $ link_text = $ this -> t ( 'Add a new @entity_type.' , [ '@entity_type' => $ type_label ] ) ; $ build [ '#add_bundle_message' ] = $ this -> t ( 'There is no @entity_type yet. @add_link' , [ '@entity_type' => $ type_label , '@add_link' => Link :: createFromRoute ( $ link_text , $ bundle_add_form ) -> toString ( ) , ] ) ; return $ build ; }
docstring: Renders a list of content types to add as members.
docstring_tokens: Renders a list of content types to add as members .