Completed
Pull Request — develop (#1576)
by Naveen
01:46
created
src/modules/pods/includes/FieldDefinition/FieldDefinitionFactory.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -7,29 +7,29 @@
 block discarded – undo
7 7
 
8 8
 class FieldDefinitionFactory {
9 9
 
10
-	/**
11
-	 * @var $schema Schema
12
-	 */
13
-	private $schema;
10
+    /**
11
+     * @var $schema Schema
12
+     */
13
+    private $schema;
14 14
 
15
-	public function __construct( $schema ) {
16
-		$this->schema = $schema;
17
-	}
15
+    public function __construct( $schema ) {
16
+        $this->schema = $schema;
17
+    }
18 18
 
19 19
 
20
-	public function get_field_definition() {
20
+    public function get_field_definition() {
21 21
 
22
-		$context_type = $this->schema->get_context_type();
22
+        $context_type = $this->schema->get_context_type();
23 23
 
24
-		switch ( $context_type ) {
25
-			case Context::POST:
26
-				return new PostTypeDefinition( $this->schema );
27
-			case Context::TERM:
28
-				return new TaxonomyDefinition( $this->schema );
29
-			default:
30
-				return new AllPodsDefiniton( $this->schema );
31
-		}
32
-	}
24
+        switch ( $context_type ) {
25
+            case Context::POST:
26
+                return new PostTypeDefinition( $this->schema );
27
+            case Context::TERM:
28
+                return new TaxonomyDefinition( $this->schema );
29
+            default:
30
+                return new AllPodsDefiniton( $this->schema );
31
+        }
32
+    }
33 33
 
34 34
 
35 35
 }
Please login to merge, or discard this patch.
src/modules/pods/includes/FieldDefinition/PostTypeDefinition.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -4,14 +4,14 @@
 block discarded – undo
4 4
 
5 5
 class PostTypeDefinition extends AbstractFieldDefiniton {
6 6
 
7
-	public function register() {
8
-		$that = $this;
9
-		add_action(
10
-			'init',
11
-			function () use ( $that ) {
12
-				$context = $that->schema->get();
13
-				$that->register_pod( $context->get_pod_name(), $context->get_pod_type(), $context );
14
-			}
15
-		);
16
-	}
7
+    public function register() {
8
+        $that = $this;
9
+        add_action(
10
+            'init',
11
+            function () use ( $that ) {
12
+                $context = $that->schema->get();
13
+                $that->register_pod( $context->get_pod_name(), $context->get_pod_type(), $context );
14
+            }
15
+        );
16
+    }
17 17
 }
Please login to merge, or discard this patch.
src/modules/pods/includes/FieldDefinition/TaxonomyDefinition.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -4,14 +4,14 @@
 block discarded – undo
4 4
 
5 5
 class TaxonomyDefinition extends AbstractFieldDefiniton {
6 6
 
7
-	public function register() {
8
-		$that = $this;
9
-		add_action(
10
-			'setup_theme',
11
-			function () use ( $that ) {
12
-				$context = $that->schema->get();
13
-				$that->register_pod( $context->get_pod_name(), $context->get_pod_type(), $context );
14
-			}
15
-		);
16
-	}
7
+    public function register() {
8
+        $that = $this;
9
+        add_action(
10
+            'setup_theme',
11
+            function () use ( $that ) {
12
+                $context = $that->schema->get();
13
+                $that->register_pod( $context->get_pod_name(), $context->get_pod_type(), $context );
14
+            }
15
+        );
16
+    }
17 17
 }
Please login to merge, or discard this patch.
src/modules/pods/includes/Schema.php 1 patch
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -4,100 +4,100 @@
 block discarded – undo
4 4
 
5 5
 class Schema {
6 6
 
7
-	public function get_context_type() {
8
-
9
-		if ( isset( $_REQUEST['post'] ) ) {
10
-			return Context::POST;
11
-		}
12
-		if ( isset( $_REQUEST['tag_ID'] ) ) {
13
-			return Context::TERM;
14
-		}
15
-
16
-		if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
17
-			return Context::ADMIN_AJAX;
18
-		}
19
-
20
-		return Context::UNKNOWN;
21
-	}
22
-
23
-
24
-	/**
25
-	 * @return Context
26
-	 */
27
-	public function get() {
28
-		// we need to identify the context to filter the results.
29
-
30
-		$identifier = isset( $_REQUEST['post'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['post'] ) ) : '';
31
-
32
-		if ( $identifier ) {
33
-			// If post identifier, get schema.
34
-			return new Context( Context::POST, $identifier, $this->get_fields_for_post( $identifier ) );
35
-		}
36
-
37
-		$identifier = isset( $_REQUEST['tag_ID'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['tag_ID'] ) ) : '';
38
-
39
-		if ( $identifier ) {
40
-			// If post identifier, get schema.
41
-			return new Context( Context::TERM, $identifier, $this->get_fields_for_term( $identifier ) );
42
-		}
43
-
44
-		if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
45
-			return new Context( Context::UNKNOWN, null, null );
46
-		}
47
-
48
-		return new Context( Context::ADMIN_AJAX, null, $this->get_all_fields() );
49
-
50
-	}
51
-
52
-	/**
53
-	 * @return Schema_Field_Group[]
54
-	 */
55
-	private function get_fields_for_post( $identifier ) {
56
-		$types          = \Wordlift_Entity_Type_Service::get_instance()->get_names( $identifier );
57
-		$schema_classes = \Wordlift_Schema_Service::get_instance();
58
-
59
-		return array_map(
60
-			function ( $schema_type ) use ( $schema_classes ) {
61
-				$data = $schema_classes->get_schema( strtolower( $schema_type ) );
62
-
63
-				return new Schema_Field_Group( $schema_type, $data['custom_fields'] );
64
-			},
65
-			$types
66
-		);
67
-	}
68
-
69
-	/**
70
-	 * @return Schema_Field_Group[]
71
-	 */
72
-	private function get_fields_for_term( $identifier ) {
73
-		$term_entity_types = get_term_meta( (int) $identifier, \Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
74
-		$schema_classes    = \Wordlift_Schema_Service::get_instance();
75
-
76
-		return array_map(
77
-			function ( $schema_type ) use ( $schema_classes ) {
78
-				$data = $schema_classes->get_schema( strtolower( $schema_type ) );
79
-
80
-				return new Schema_Field_Group( $schema_type, $data['custom_fields'] );
81
-			},
82
-			$term_entity_types
83
-		);
84
-	}
85
-
86
-	private function get_all_fields() {
87
-		$schema_classes   = \Wordlift_Schema_Service::get_instance();
88
-		$all_schema_slugs = $schema_classes->get_all_schema_slugs();
89
-
90
-		return array_filter(
91
-			array_map(
92
-				function ( $schema_type ) use ( $schema_classes ) {
93
-					$data = $schema_classes->get_schema( strtolower( $schema_type ) );
94
-
95
-					return new Schema_Field_Group( $schema_type, $data['custom_fields'] );
96
-				},
97
-				$all_schema_slugs
98
-			)
99
-		);
100
-	}
7
+    public function get_context_type() {
8
+
9
+        if ( isset( $_REQUEST['post'] ) ) {
10
+            return Context::POST;
11
+        }
12
+        if ( isset( $_REQUEST['tag_ID'] ) ) {
13
+            return Context::TERM;
14
+        }
15
+
16
+        if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
17
+            return Context::ADMIN_AJAX;
18
+        }
19
+
20
+        return Context::UNKNOWN;
21
+    }
22
+
23
+
24
+    /**
25
+     * @return Context
26
+     */
27
+    public function get() {
28
+        // we need to identify the context to filter the results.
29
+
30
+        $identifier = isset( $_REQUEST['post'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['post'] ) ) : '';
31
+
32
+        if ( $identifier ) {
33
+            // If post identifier, get schema.
34
+            return new Context( Context::POST, $identifier, $this->get_fields_for_post( $identifier ) );
35
+        }
36
+
37
+        $identifier = isset( $_REQUEST['tag_ID'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['tag_ID'] ) ) : '';
38
+
39
+        if ( $identifier ) {
40
+            // If post identifier, get schema.
41
+            return new Context( Context::TERM, $identifier, $this->get_fields_for_term( $identifier ) );
42
+        }
43
+
44
+        if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
45
+            return new Context( Context::UNKNOWN, null, null );
46
+        }
47
+
48
+        return new Context( Context::ADMIN_AJAX, null, $this->get_all_fields() );
49
+
50
+    }
51
+
52
+    /**
53
+     * @return Schema_Field_Group[]
54
+     */
55
+    private function get_fields_for_post( $identifier ) {
56
+        $types          = \Wordlift_Entity_Type_Service::get_instance()->get_names( $identifier );
57
+        $schema_classes = \Wordlift_Schema_Service::get_instance();
58
+
59
+        return array_map(
60
+            function ( $schema_type ) use ( $schema_classes ) {
61
+                $data = $schema_classes->get_schema( strtolower( $schema_type ) );
62
+
63
+                return new Schema_Field_Group( $schema_type, $data['custom_fields'] );
64
+            },
65
+            $types
66
+        );
67
+    }
68
+
69
+    /**
70
+     * @return Schema_Field_Group[]
71
+     */
72
+    private function get_fields_for_term( $identifier ) {
73
+        $term_entity_types = get_term_meta( (int) $identifier, \Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
74
+        $schema_classes    = \Wordlift_Schema_Service::get_instance();
75
+
76
+        return array_map(
77
+            function ( $schema_type ) use ( $schema_classes ) {
78
+                $data = $schema_classes->get_schema( strtolower( $schema_type ) );
79
+
80
+                return new Schema_Field_Group( $schema_type, $data['custom_fields'] );
81
+            },
82
+            $term_entity_types
83
+        );
84
+    }
85
+
86
+    private function get_all_fields() {
87
+        $schema_classes   = \Wordlift_Schema_Service::get_instance();
88
+        $all_schema_slugs = $schema_classes->get_all_schema_slugs();
89
+
90
+        return array_filter(
91
+            array_map(
92
+                function ( $schema_type ) use ( $schema_classes ) {
93
+                    $data = $schema_classes->get_schema( strtolower( $schema_type ) );
94
+
95
+                    return new Schema_Field_Group( $schema_type, $data['custom_fields'] );
96
+                },
97
+                $all_schema_slugs
98
+            )
99
+        );
100
+    }
101 101
 
102 102
 
103 103
 }
Please login to merge, or discard this patch.