You are here

public function CheeseburgerMenu::blockValidate in Cheeseburger Menu 8.4

Overrides BlockPluginTrait::blockValidate

File

src/Plugin/Block/CheeseburgerMenu.php, line 450
Cheeseburger class extends BlockBase.

Class

CheeseburgerMenu
Block info.

Namespace

Drupal\cheeseburger_menu\Plugin\Block

Code

public function blockValidate($form, FormStateInterface $form_state) {
  parent::blockValidate($form, $form_state);
  $values = $form_state
    ->getValues();
  if (array_key_exists('breakpoints', $values) && $values['breakpoints']['all'] == '0') {
    $breakpoints = $this->renderCheesebugerMenuService
      ->returnBreakpointsForDefaultTheme();
    $breakpoints_order = [
      '0',
    ];
    foreach ($breakpoints as $breakpoint_name => $breakpoint) {
      $breakpoints_order[] = $breakpoint_name;
    }
    if (array_search($values['breakpoints']['from'], $breakpoints_order) >= array_search($values['breakpoints']['to'], $breakpoints_order)) {
      $form_state
        ->setErrorByName('from', $this
        ->t('The first breakpoint should be smaller than second!'));
    }
  }
}