You are here

public function Layout::getLayoutOptions in Bootstrap Layout Builder 2.x

Same name and namespace in other branches
  1. 1.x src/Entity/Layout.php \Drupal\bootstrap_layout_builder\Entity\Layout::getLayoutOptions()

Returns all the options from a layout options sorted correctly.

Return value

\Drupal\bootstrap_layout_builder\LayoutOptionInterface[] An array of layout options entities.

Overrides LayoutInterface::getLayoutOptions

File

src/Entity/Layout.php, line 88

Class

Layout
Defines the layout configuration entity.

Namespace

Drupal\bootstrap_layout_builder\Entity

Code

public function getLayoutOptions() {
  $options = $this
    ->entityTypeManager()
    ->getStorage('blb_layout_option')
    ->loadByProperties([
    'layout_id' => $this
      ->id(),
  ]);
  uasort($options, function ($a, $b) {
    $a_weight = $a
      ->getWeight();
    $b_weight = $b
      ->getWeight();
    if ($a_weight == $b_weight) {
      return strnatcasecmp($a
        ->label(), $b
        ->label());
    }
    return $a_weight < $b_weight ? -1 : 1;
  });
  return $options;
}