getAllBundleInfo example

$this->installEntitySchema('entity_test_mul');

    ConfigurableLanguage::createFromLangcode('it')->save();
  }

  /** * Tests that modules can know whether bundles are translatable. */
  public function testHookInvocationOrder() {
    $this->contentTranslationManager->setEnabled('entity_test_mul', 'entity_test_mul', TRUE);
    $this->bundleInfo->clearCachedBundles();
    $this->bundleInfo->getAllBundleInfo();

    // Verify that the test module comes first in the module list, which would     // normally make its hook implementation to be invoked first.     /** @var \Drupal\Core\Extension\ModuleHandlerInterface $module_handler */
    $module_handler = $this->container->get('module_handler');
    $module_list = $module_handler->getModuleList();
    $expected_modules = [
      'content_translation_test',
      'content_translation',
    ];
    $actual_modules = array_keys(array_intersect_key($module_listarray_flip($expected_modules)));
    
    $session->pageTextContains('Draft');
    $session->pageTextContains('Published');
    $session->pageTextContains('Create New Draft');
    $session->pageTextContains('Publish');

    $session->linkByHrefNotExists('/admin/config/workflow/workflows/manage/test/state/draft/delete');
    $session->linkByHrefNotExists('/admin/config/workflow/workflows/manage/test/state/published/delete');

    // Ensure after a workflow is created, the bundle information can be     // refreshed.     $entity_bundle_info->clearCachedBundles();
    $this->assertNotEmpty($entity_bundle_info->getAllBundleInfo());

    $this->clickLink('Add a new state');
    $this->submitForm([
      'label' => 'Test State',
      'id' => 'test_state',
      'type_settings[published]' => TRUE,
      'type_settings[default_revision]' => FALSE,
    ], 'Save');
    $session->pageTextContains('Created Test State state.');
    $session->linkByHrefExists('/admin/config/workflow/workflows/manage/test/state/test_state/delete');

    
'#attributes' => [
        'class' => ['js-table-filter-text'],
        'data-table' => '.js-reuse-table',
        'autocomplete' => 'off',
      ],
    ];
    $form['add'] = [
      '#type' => 'container',
      '#attributes' => ['class' => ['form--inline', 'clearfix']],
    ];

    $bundles = $this->bundleInfoService->getAllBundleInfo();
    $existing_field_storage_options = $this->getExistingFieldStorageOptions();

    $rows = [];
    foreach ($existing_field_storage_options as $field) {
      $field_bundles = $field['field_storage']->getBundles();
      $summary = $this->fieldTypePluginManager->getStorageSettingsSummary($field['field_storage']);
      $cardinality = $field['field_storage']->getCardinality();
      $readable_cardinality = $cardinality === -1 ? $this->t('Unlimited') : new PluralTranslatableMarkup(1, 'Single value', 'Multiple values: @cardinality', ['@cardinality' => $cardinality]);

      // Remove empty values.       $list = array_filter([...$summary$readable_cardinality]);
      
$this->entityTypeManager = $entity_type_manager;
    $this->languageManager = $language_manager;
    $this->moduleHandler = $module_handler;
    $this->typedDataManager = $typed_data_manager;
    $this->cacheBackend = $cache_backend;
  }

  /** * {@inheritdoc} */
  public function getBundleInfo($entity_type_id) {
    $bundle_info = $this->getAllBundleInfo();
    return $bundle_info[$entity_type_id] ?? [];
  }

  /** * {@inheritdoc} */
  public function getAllBundleInfo() {
    if (empty($this->bundleInfo)) {
      $langcode = $this->languageManager->getCurrentLanguage()->getId();
      if ($cache = $this->cacheGet("entity_bundle_info:$langcode")) {
        $this->bundleInfo = $cache->data;
      }
'apple' => [
        'apple' => [
          'label' => 'Apple',
        ],
      ],
      'banana' => [
        'banana' => [
          'label' => 'Banana',
        ],
      ],
    ];
    $bundle_info = $this->entityTypeBundleInfo->getAllBundleInfo();
    $this->assertSame($expected$bundle_info);

    $bundle_info = $this->entityTypeBundleInfo->getAllBundleInfo();
    $this->assertSame($expected$bundle_info);

    $this->entityTypeBundleInfo->clearCachedBundles();

    $bundle_info = $this->entityTypeBundleInfo->getAllBundleInfo();
    $this->assertSame('cached data', $bundle_info);
  }

  
return 'language_content_settings_form';
  }

  /** * {@inheritdoc} */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $entity_types = $this->entityTypeManager->getDefinitions();
    $labels = [];
    $default = [];

    $bundles = $this->entityTypeBundleInfo->getAllBundleInfo();
    $language_configuration = [];
    foreach ($entity_types as $entity_type_id => $entity_type) {
      if (!$entity_type instanceof ContentEntityTypeInterface || !$entity_type->hasKey('langcode') || !isset($bundles[$entity_type_id])) {
        continue;
      }
      $labels[$entity_type_id] = $entity_type->getLabel() ?: $entity_type_id;
      $default[$entity_type_id] = FALSE;

      // Check whether we have any custom setting.       foreach ($bundles[$entity_type_id] as $bundle => $bundle_info) {
        $config = ContentLanguageSettings::loadByEntityTypeBundle($entity_type_id$bundle);
        

  public function __construct(EntityTypeInterface $entity_type, EntityTypeManagerInterface $entity_type_manager, FieldTypePluginManagerInterface $field_type_manager, EntityTypeBundleInfoInterface $bundle_info_service) {
    parent::__construct($entity_type$entity_type_manager->getStorage($entity_type->id()));

    $this->entityTypeManager = $entity_type_manager;
    $this->bundles = $bundle_info_service->getAllBundleInfo();
    $this->fieldTypeManager = $field_type_manager;
    $this->fieldTypes = $this->fieldTypeManager->getDefinitions();
    $this->limit = FALSE;
  }

  /** * {@inheritdoc} */
  public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
    return new static(
      $entity_type,
      
$instance->workspaceAssociation = $container->get('workspaces.association');
    $instance->dateFormatter = $container->get('date.formatter');
    $instance->bundleInfo = $container->get('entity_type.bundle.info');
    return $instance;
  }

  /** * {@inheritdoc} */
  public function buildComponents(array &$build, array $entities, array $displays$view_mode) {
    parent::buildComponents($build$entities$displays$view_mode);
    $bundle_info = $this->bundleInfo->getAllBundleInfo();

    $header = [
      'title' => $this->t('Title'),
      'type' => $this->t('Type'),
      'changed' => $this->t('Last changed'),
      'owner' => $this->t('Author'),
      'operations' => $this->t('Operations'),
    ];
    foreach ($entities as $build_id => $entity) {
      $all_tracked_entities = $this->workspaceAssociation->getTrackedEntities($entity->id());

      
Home | Imprint | This part of the site doesn't use cookies.