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