getBreakpointsByGroup example

'multiplier' => $multiplier,
    ];
    $this->sortMappings();
    return $this;
  }

  /** * Sort mappings by breakpoint ID and multiplier. */
  protected function sortMappings(): void {
    $this->keyedImageStyleMappings = NULL;
    $breakpoints = \Drupal::service('breakpoint.manager')->getBreakpointsByGroup($this->getBreakpointGroup());
    if (empty($breakpoints)) {
      return;
    }
    usort($this->image_style_mappings, static function Darray $a, array $b) use ($breakpoints): int {
      $breakpoint_a = $breakpoints[$a['breakpoint_id']] ?? NULL;
      $breakpoint_b = $breakpoints[$b['breakpoint_id']] ?? NULL;
      $first = ((float) mb_substr($a['multiplier'], 0, -1)) * 100;
      $second = ((float) mb_substr($b['multiplier'], 0, -1)) * 100;
      return [$breakpoint_b ? $breakpoint_b->getWeight() : 0, $first] <=> [$breakpoint_a ? $breakpoint_a->getWeight() : 0, $second];
    });
  }

  

  public static function preRenderToolbar($element) {
    // Get the configured breakpoints to switch from vertical to horizontal     // toolbar presentation.     $breakpoints = static::breakpointManager()->getBreakpointsByGroup('toolbar');
    if (!empty($breakpoints)) {
      $media_queries = [];
      foreach ($breakpoints as $id => $breakpoint) {
        $media_queries[$id] = $breakpoint->getMediaQuery();
      }

      $element['#attached']['drupalSettings']['toolbar']['breakpoints'] = $media_queries;
    }

    $module_handler = static::moduleHandler();
    // Get toolbar items from all modules that implement hook_toolbar().
'#type' => 'container',
      '#attributes' => [
        'id' => 'responsive-image-style-breakpoints-wrapper',
      ],
    ];

    // By default, breakpoints are ordered from smallest weight to largest:     // the smallest weight is expected to have the smallest breakpoint width,     // while the largest weight is expected to have the largest breakpoint     // width. For responsive images, we need largest breakpoint widths first, so     // we need to reverse the order of these breakpoints.     $breakpoints = array_reverse($this->breakpointManager->getBreakpointsByGroup($responsive_image_style->getBreakpointGroup()));

    foreach ($breakpoints as $breakpoint_id => $breakpoint) {
      foreach ($breakpoint->getMultipliers() as $multiplier) {
        $label = $multiplier . ' ' . $breakpoint->getLabel() . ' [' . $breakpoint->getMediaQuery() . ']';
        $form['keyed_styles'][$breakpoint_id][$multiplier] = [
          '#type' => 'details',
          '#title' => $label,
        ];
        $image_style_mapping = $responsive_image_style->getImageStyleMapping($breakpoint_id$multiplier);
        if (\Drupal::moduleHandler()->moduleExists('help')) {
          $description = $this->t('See the <a href=":responsive_image_help">Responsive Image help page</a> for information on the sizes attribute.', [':responsive_image_help' => Url::fromRoute('help.page', ['name' => 'responsive_image'])->toString()]);
        }
'weight' => 3,
        'multipliers' => [
          '1x',
        ],
        'provider' => 'breakpoint_theme_test',
        'id' => 'breakpoint_theme_test.tv',
        'group' => 'breakpoint_theme_test',
        'class' => 'Drupal\\breakpoint\\Breakpoint',
      ],
    ];

    $breakpoints = \Drupal::service('breakpoint.manager')->getBreakpointsByGroup('breakpoint_theme_test');
    foreach ($expected_breakpoints as $id => $expected_breakpoint) {
      $this->assertEquals($expected_breakpoint$breakpoints[$id]->getPluginDefinition());
    }

    // Test that the order is as expected.     $this->assertSame(array_keys($expected_breakpoints)array_keys($breakpoints));
  }

  /** * Tests the custom breakpoint group provided by a theme and a module. */
  
$group_labels[$group] = $this->getGroupLabel($group);
    }
    asort($group_labels);
    return $group_labels;
  }

  /** * {@inheritdoc} */
  public function getGroupProviders($group) {
    $providers = [];
    $breakpoints = $this->getBreakpointsByGroup($group);
    foreach ($breakpoints as $breakpoint) {
      $provider = $breakpoint->getProvider();
      $extension = FALSE;
      if ($this->moduleHandler->moduleExists($provider)) {
        $extension = $this->moduleHandler->getModule($provider);
      }
      elseif ($this->themeHandler->themeExists($provider)) {
        $extension = $this->themeHandler->getTheme($provider);
      }
      if ($extension) {
        $providers[$extension->getName()] = $extension->getType();
      }
Home | Imprint | This part of the site doesn't use cookies.