| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\GlobalClasses; |
| 4 |
|
| 5 |
use Elementor\Core\Utils\Collection; |
| 6 |
|
| 7 |
class Global_Classes { |
| 8 |
private Collection $items; |
| 9 |
private Collection $order; |
| 10 |
private Collection $ordered_items; |
| 11 |
|
| 12 |
public static function make( array $items = [], array $order = [] ) { |
| 13 |
return new static( $items, $order ); |
| 14 |
} |
| 15 |
|
| 16 |
private function __construct( array $data = [], array $order = [] ) { |
| 17 |
$this->items = Collection::make( $data ); |
| 18 |
$this->order = Collection::make( $order ); |
| 19 |
$this->ordered_items = $this->order |
| 20 |
->map( fn( $id ) => $data[ $id ] ?? null ) |
| 21 |
->filter( fn( $item ) => null !== $item ); |
| 22 |
} |
| 23 |
|
| 24 |
public function get_items() { |
| 25 |
return $this->items; |
| 26 |
} |
| 27 |
|
| 28 |
public function get_order() { |
| 29 |
return $this->order; |
| 30 |
} |
| 31 |
|
| 32 |
public function get_ordered_items() { |
| 33 |
return $this->ordered_items; |
| 34 |
} |
| 35 |
|
| 36 |
public function get() { |
| 37 |
return [ |
| 38 |
'items' => $this->get_items()->all(), |
| 39 |
'order' => $this->get_order()->all(), |
| 40 |
]; |
| 41 |
} |
| 42 |
} |
| 43 |
|