getFilteredDefinitions example


  public function build(SectionStorageInterface $section_storage, int $delta) {
    $items = [];
    $definitions = $this->layoutManager->getFilteredDefinitions('layout_builder', $this->getPopulatedContexts($section_storage)['section_storage' => $section_storage]);
    foreach ($definitions as $plugin_id => $definition) {
      $layout = $this->layoutManager->createInstance($plugin_id);
      $item = [
        '#type' => 'link',
        '#title' => [
          'icon' => $definition->getIcon(60, 80, 1, 3),
          'label' => [
            '#type' => 'container',
            '#children' => $definition->getLabel(),
          ],
        ],
        
->willReturn(['plugin2' => $definitions['plugin2']]);

    // After context filtering, the alter hook will be invoked.     $module_handler = $this->prophesize(ModuleHandlerInterface::class);
    $hooks = ["plugin_filter_{$type}", "plugin_filter_{$type}__{$consumer}"];
    $module_handler->alter($hooks$expected$extra$consumer)->shouldBeCalled();

    $theme_manager = $this->prophesize(ThemeManagerInterface::class);
    $theme_manager->alter($hooks$expected$extra$consumer)->shouldBeCalled();

    $plugin_manager = new TestFilteredPluginManager($definitions$module_handler->reveal()$theme_manager->reveal()$context_handler->reveal());
    $result = $plugin_manager->getFilteredDefinitions($consumer$contexts$extra);
    $this->assertSame($expected$result);
  }

  /** * Provides test data for ::testGetFilteredDefinitions(). */
  public function providerTestGetFilteredDefinitions() {
    $data = [];
    $data['populated context'] = [
      ['context1' => 'fake context'],
      ['plugin1' => ['id' => 'plugin1']],
    ];
'#title' => $this->t('Visibility'),
      '#parents' => ['visibility_tabs'],
      '#attached' => [
        'library' => [
          'block/drupal.block',
        ],
      ],
    ];
    // @todo Allow list of conditions to be configured in     // https://www.drupal.org/node/2284687.     $visibility = $this->entity->getVisibility();
    $definitions = $this->manager->getFilteredDefinitions('block_ui', $form_state->getTemporaryValue('gathered_contexts')['block' => $this->entity]);
    foreach ($definitions as $condition_id => $definition) {
      // Don't display the current theme condition.       if ($condition_id == 'current_theme') {
        continue;
      }
      // Don't display the language condition until we have multiple languages.       if ($condition_id == 'language' && !$this->language->isMultilingual()) {
        continue;
      }

      /** @var \Drupal\Core\Condition\ConditionInterface $condition */
      
'#attributes' => [
        'class' => ['js-layout-builder-filter'],
        'title' => $this->t('Enter a part of the block name to filter by.'),
      ],
    ];

    $block_categories['#type'] = 'container';
    $block_categories['#attributes']['class'][] = 'block-categories';
    $block_categories['#attributes']['class'][] = 'js-layout-builder-categories';
    $block_categories['#attributes']['data-layout-builder-target-highlight-id'] = $this->blockAddHighlightId($delta$region);

    $definitions = $this->blockManager->getFilteredDefinitions('layout_builder', $this->getPopulatedContexts($section_storage)[
      'section_storage' => $section_storage,
      'delta' => $delta,
      'region' => $region,
    ]);
    $grouped_definitions = $this->blockManager->getGroupedDefinitions($definitions);
    foreach ($grouped_definitions as $category => $blocks) {
      $block_categories[$category]['#type'] = 'details';
      $block_categories[$category]['#attributes']['class'][] = 'js-layout-builder-category';
      $block_categories[$category]['#open'] = TRUE;
      $block_categories[$category]['#title'] = $category;
      $block_categories[$category]['links'] = $this->getBlockLinks($section_storage$delta$region$blocks);
    }
$headers = [
      ['data' => $this->t('Block')],
      ['data' => $this->t('Category')],
      ['data' => $this->t('Operations')],
    ];

    $region = $request->query->get('region');
    $weight = $request->query->get('weight');

    // Only add blocks which work without any available context.     $definitions = $this->blockManager->getFilteredDefinitions('block_ui', $this->contextRepository->getAvailableContexts()[
      'theme' => $theme,
      'region' => $region,
    ]);
    // Order by category, and then by admin label.     $definitions = $this->blockManager->getSortedDefinitions($definitions);
    // Filter out definitions that are not intended to be placed by the UI.     $definitions = array_filter($definitionsfunction Darray $definition) {
      return empty($definition['_block_ui_hidden']);
    });

    $rows = [];
    
Home | Imprint | This part of the site doesn't use cookies.