PluginProbe
Elementor Website Builder – more than just a page builder / 3.11.5
Elementor Website Builder – more than just a page builder v3.11.5
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
elementor / data / v2 / base / endpoint / index / all-children.php

all-children.php in Elementor Website Builder – more than just a page builder 3.11.5, at data/v2/base/endpoint/index/all-children.php

76 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Data\V2\Base\Endpoint\Index;
3
4 use Elementor\Data\V2\Base\Endpoint\Index;
5 use Elementor\Data\V2\Manager;
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit; // Exit if accessed directly
9 }
10 /**
11 * class AllChildren, is optional endpoint.
12 * Used in cases where the endpoints are static & there no use of dynamic endpoints( alpha/{id} ), eg:
13 * 'settings' - controller
14 * 'settings/products' - endpoint
15 * 'settings/partners' - endpoint
16 *
17 * When 'settings' is requested, it should return results of all endpoints ( except it self ):
18 * 'settings/products
19 * 'settings/partners'
20 * By running 'get_items' of each endpoint.
21 */
22 class AllChildren extends Index {
23 public function get_format() {
24 return $this->controller->get_name() . '/index';
25 }
26
27 /*
28 * Retrieves a result(s) of all controller endpoint(s), items.
29 *
30 * Run overall endpoints of the current controller.
31 *
32 * Example, scenario:
33 * 'settings' - controller
34 * 'settings/products' - endpoint
35 * 'settings/partners' - endpoint
36 * Result:
37 * [
38 * 'products' => [
39 * 0 => ...
40 * 1 => ...
41 * ],
42 * 'partners' => [
43 * 0 => ...
44 * 1 => ...
45 * ],
46 * ]
47 */
48 public function get_items( $request ) {
49 $response = [];
50
51 foreach ( $this->controller->get_sub_controllers() as $controller ) {
52 $controller_route = $this->get_controller()->get_base_route() . '/' . $controller->get_name();
53 $result = Manager::instance()->run_request( $controller_route );
54
55 if ( ! $result->is_error() ) {
56 $response[ $controller->get_name() ] = $result->get_data();
57 }
58 }
59
60 foreach ( $this->controller->endpoints as $endpoint ) {
61 // Skip self.
62 if ( $endpoint === $this ) {
63 continue;
64 }
65
66 $result = Manager::instance()->run_request( $endpoint->get_base_route() );
67
68 if ( ! $result->is_error() ) {
69 $response[ $endpoint->get_name() ] = $result->get_data();
70 }
71 }
72
73 return $response;
74 }
75 }
76