PluginProbe
Elementor Website Builder – more than just a page builder / 4.0.3
Elementor Website Builder – more than just a page builder v4.0.3
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 4.0.3, at data/v2/base/endpoint/index/all-children.php

77 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 * All Children class, is an optional endpoint.
12 *
13 * Used in cases where the endpoints are static & there no use of dynamic endpoints( alpha/{id} ), eg:
14 * 'settings' - controller
15 * 'settings/products' - endpoint
16 * 'settings/partners' - endpoint
17 *
18 * When 'settings' is requested, it should return results of all endpoints ( except it self ):
19 * 'settings/products
20 * 'settings/partners'
21 * By running 'get_items' of each endpoint.
22 */
23 class AllChildren extends Index {
24 public function get_format() {
25 return $this->controller->get_name() . '/index';
26 }
27
28 /**
29 * Retrieves a result(s) of all controller endpoint(s), items.
30 *
31 * Run overall endpoints of the current controller.
32 *
33 * Example, scenario:
34 * 'settings' - controller
35 * 'settings/products' - endpoint
36 * 'settings/partners' - endpoint
37 * Result:
38 * [
39 * 'products' => [
40 * 0 => ...
41 * 1 => ...
42 * ],
43 * 'partners' => [
44 * 0 => ...
45 * 1 => ...
46 * ],
47 * ]
48 */
49 public function get_items( $request ) {
50 $response = [];
51
52 foreach ( $this->controller->get_sub_controllers() as $controller ) {
53 $controller_route = $this->get_controller()->get_base_route() . '/' . $controller->get_name();
54 $result = Manager::instance()->run_request( $controller_route );
55
56 if ( ! $result->is_error() ) {
57 $response[ $controller->get_name() ] = $result->get_data();
58 }
59 }
60
61 foreach ( $this->controller->endpoints as $endpoint ) {
62 // Skip self.
63 if ( $endpoint === $this ) {
64 continue;
65 }
66
67 $result = Manager::instance()->run_request( $endpoint->get_base_route() );
68
69 if ( ! $result->is_error() ) {
70 $response[ $endpoint->get_name() ] = $result->get_data();
71 }
72 }
73
74 return $response;
75 }
76 }
77