Completed
Pull Request — develop (#1417)
by Naveen
54s
created
src/wordlift/vocabulary-terms/class-entity-type.php 2 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -14,49 +14,49 @@  discard block
 block discarded – undo
14 14
 
15 15
 class Entity_Type {
16 16
 
17
-	public function __construct() {
17
+    public function __construct() {
18 18
 
19
-		$taxonomies = Terms_Compat::get_public_taxonomies();
20
-		foreach ( $taxonomies as $taxonomy ) {
21
-			add_action( "${taxonomy}_edit_form_fields", array( $this, 'render_ui' ), 1 );
22
-			add_action( "edited_${taxonomy}", array( $this, 'save_field' ) );
23
-		}
19
+        $taxonomies = Terms_Compat::get_public_taxonomies();
20
+        foreach ( $taxonomies as $taxonomy ) {
21
+            add_action( "${taxonomy}_edit_form_fields", array( $this, 'render_ui' ), 1 );
22
+            add_action( "edited_${taxonomy}", array( $this, 'save_field' ) );
23
+        }
24 24
 
25
-	}
25
+    }
26 26
 
27 27
 
28
-	/**
29
-	 * @param $term  \WP_Term
30
-	 */
31
-	public function render_ui( $term ) {
28
+    /**
29
+     * @param $term  \WP_Term
30
+     */
31
+    public function render_ui( $term ) {
32 32
 
33 33
 
34
-		$entity_types_text     = __( 'Entity Types', 'wordlift' );
35
-		$selected_entity_types = get_term_meta( $term->term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
34
+        $entity_types_text     = __( 'Entity Types', 'wordlift' );
35
+        $selected_entity_types = get_term_meta( $term->term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
36 36
 
37
-		/**
38
-		 * Thing should be the default selected entity type
39
-		 * when this feature is activated.
40
-		 */
41
-		if ( count($selected_entity_types) === 0 ) {
42
-			$selected_entity_types[] = 'thing';
43
-		}
37
+        /**
38
+         * Thing should be the default selected entity type
39
+         * when this feature is activated.
40
+         */
41
+        if ( count($selected_entity_types) === 0 ) {
42
+            $selected_entity_types[] = 'thing';
43
+        }
44 44
 
45 45
 
46
-		$entity_type_taxonomy  = Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME;
47
-		$types                 = Terms_Compat::get_terms(
48
-			$entity_type_taxonomy,
49
-			array(
50
-				'taxonomy'   => $entity_type_taxonomy,
51
-				'parent'     => 0,
52
-				'hide_empty' => false
53
-			)
54
-		);
46
+        $entity_type_taxonomy  = Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME;
47
+        $types                 = Terms_Compat::get_terms(
48
+            $entity_type_taxonomy,
49
+            array(
50
+                'taxonomy'   => $entity_type_taxonomy,
51
+                'parent'     => 0,
52
+                'hide_empty' => false
53
+            )
54
+        );
55 55
 
56
-		$terms_html = Term_Checklist::render( 'tax_input[wl_entity_type]', $types, $selected_entity_types );
56
+        $terms_html = Term_Checklist::render( 'tax_input[wl_entity_type]', $types, $selected_entity_types );
57 57
 
58 58
 
59
-		$template = <<<EOF
59
+        $template = <<<EOF
60 60
         <tr class="form-field term-name-wrap">
61 61
             <th scope="row"><label for="wl-entity-type__checklist">%s</label></th>
62 62
             <td>
@@ -66,21 +66,21 @@  discard block
 block discarded – undo
66 66
 EOF;
67 67
 
68 68
 
69
-		echo sprintf( $template, $entity_types_text, $terms_html );
70
-	}
71
-
72
-	public function save_field( $term_id ) {
73
-		if ( ! isset( $_REQUEST['tax_input'] )  ) {
74
-			return;
75
-		}
76
-		$entity_types = $_REQUEST['tax_input'][ Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ];
77
-		if ( isset( $entity_types ) && is_array( $entity_types ) ) {
78
-			// Save the taxonomies.
79
-			delete_term_meta( $term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
80
-			foreach ( $entity_types as $entity_type ) {
81
-				add_term_meta( $term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, (string) $entity_type );
82
-			}
83
-		}
84
-	}
69
+        echo sprintf( $template, $entity_types_text, $terms_html );
70
+    }
71
+
72
+    public function save_field( $term_id ) {
73
+        if ( ! isset( $_REQUEST['tax_input'] )  ) {
74
+            return;
75
+        }
76
+        $entity_types = $_REQUEST['tax_input'][ Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ];
77
+        if ( isset( $entity_types ) && is_array( $entity_types ) ) {
78
+            // Save the taxonomies.
79
+            delete_term_meta( $term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
80
+            foreach ( $entity_types as $entity_type ) {
81
+                add_term_meta( $term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, (string) $entity_type );
82
+            }
83
+        }
84
+    }
85 85
 
86 86
 }
87 87
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -17,9 +17,9 @@  discard block
 block discarded – undo
17 17
 	public function __construct() {
18 18
 
19 19
 		$taxonomies = Terms_Compat::get_public_taxonomies();
20
-		foreach ( $taxonomies as $taxonomy ) {
21
-			add_action( "${taxonomy}_edit_form_fields", array( $this, 'render_ui' ), 1 );
22
-			add_action( "edited_${taxonomy}", array( $this, 'save_field' ) );
20
+		foreach ($taxonomies as $taxonomy) {
21
+			add_action("${taxonomy}_edit_form_fields", array($this, 'render_ui'), 1);
22
+			add_action("edited_${taxonomy}", array($this, 'save_field'));
23 23
 		}
24 24
 
25 25
 	}
@@ -28,17 +28,17 @@  discard block
 block discarded – undo
28 28
 	/**
29 29
 	 * @param $term  \WP_Term
30 30
 	 */
31
-	public function render_ui( $term ) {
31
+	public function render_ui($term) {
32 32
 
33 33
 
34
-		$entity_types_text     = __( 'Entity Types', 'wordlift' );
35
-		$selected_entity_types = get_term_meta( $term->term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
34
+		$entity_types_text     = __('Entity Types', 'wordlift');
35
+		$selected_entity_types = get_term_meta($term->term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME);
36 36
 
37 37
 		/**
38 38
 		 * Thing should be the default selected entity type
39 39
 		 * when this feature is activated.
40 40
 		 */
41
-		if ( count($selected_entity_types) === 0 ) {
41
+		if (count($selected_entity_types) === 0) {
42 42
 			$selected_entity_types[] = 'thing';
43 43
 		}
44 44
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 			)
54 54
 		);
55 55
 
56
-		$terms_html = Term_Checklist::render( 'tax_input[wl_entity_type]', $types, $selected_entity_types );
56
+		$terms_html = Term_Checklist::render('tax_input[wl_entity_type]', $types, $selected_entity_types);
57 57
 
58 58
 
59 59
 		$template = <<<EOF
@@ -66,19 +66,19 @@  discard block
 block discarded – undo
66 66
 EOF;
67 67
 
68 68
 
69
-		echo sprintf( $template, $entity_types_text, $terms_html );
69
+		echo sprintf($template, $entity_types_text, $terms_html);
70 70
 	}
71 71
 
72
-	public function save_field( $term_id ) {
73
-		if ( ! isset( $_REQUEST['tax_input'] )  ) {
72
+	public function save_field($term_id) {
73
+		if ( ! isset($_REQUEST['tax_input'])) {
74 74
 			return;
75 75
 		}
76
-		$entity_types = $_REQUEST['tax_input'][ Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ];
77
-		if ( isset( $entity_types ) && is_array( $entity_types ) ) {
76
+		$entity_types = $_REQUEST['tax_input'][Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME];
77
+		if (isset($entity_types) && is_array($entity_types)) {
78 78
 			// Save the taxonomies.
79
-			delete_term_meta( $term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
80
-			foreach ( $entity_types as $entity_type ) {
81
-				add_term_meta( $term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, (string) $entity_type );
79
+			delete_term_meta($term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME);
80
+			foreach ($entity_types as $entity_type) {
81
+				add_term_meta($term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, (string) $entity_type);
82 82
 			}
83 83
 		}
84 84
 	}
Please login to merge, or discard this patch.
src/wordlift/vocabulary-terms/hooks/class-term-save.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -18,22 +18,22 @@
 block discarded – undo
18 18
  */
19 19
 class Term_Save {
20 20
 
21
-	public function init() {
22
-		add_action( 'create_term', array( $this, 'saved_term' ) );
23
-		add_action( 'edited_term', array( $this, 'saved_term' ) );
24
-	}
21
+    public function init() {
22
+        add_action( 'create_term', array( $this, 'saved_term' ) );
23
+        add_action( 'edited_term', array( $this, 'saved_term' ) );
24
+    }
25 25
 
26
-	public function saved_term( $term_id ) {
26
+    public function saved_term( $term_id ) {
27 27
 
28
-		// check if entity url already exists.
28
+        // check if entity url already exists.
29 29
 
30
-		$entity_url = get_term_meta( $term_id, WL_ENTITY_URL_META_NAME, true);
30
+        $entity_url = get_term_meta( $term_id, WL_ENTITY_URL_META_NAME, true);
31 31
 
32
-		if (  ! $entity_url ) {
33
-			// we need to build an entity uri for the term.
34
-			wl_set_term_entity_uri( $term_id, wl_build_term_uri( $term_id ) );
35
-		}
36
-	}
32
+        if (  ! $entity_url ) {
33
+            // we need to build an entity uri for the term.
34
+            wl_set_term_entity_uri( $term_id, wl_build_term_uri( $term_id ) );
35
+        }
36
+    }
37 37
 
38 38
 
39 39
 }
40 40
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -19,19 +19,19 @@
 block discarded – undo
19 19
 class Term_Save {
20 20
 
21 21
 	public function init() {
22
-		add_action( 'create_term', array( $this, 'saved_term' ) );
23
-		add_action( 'edited_term', array( $this, 'saved_term' ) );
22
+		add_action('create_term', array($this, 'saved_term'));
23
+		add_action('edited_term', array($this, 'saved_term'));
24 24
 	}
25 25
 
26
-	public function saved_term( $term_id ) {
26
+	public function saved_term($term_id) {
27 27
 
28 28
 		// check if entity url already exists.
29 29
 
30
-		$entity_url = get_term_meta( $term_id, WL_ENTITY_URL_META_NAME, true);
30
+		$entity_url = get_term_meta($term_id, WL_ENTITY_URL_META_NAME, true);
31 31
 
32
-		if (  ! $entity_url ) {
32
+		if ( ! $entity_url) {
33 33
 			// we need to build an entity uri for the term.
34
-			wl_set_term_entity_uri( $term_id, wl_build_term_uri( $term_id ) );
34
+			wl_set_term_entity_uri($term_id, wl_build_term_uri($term_id));
35 35
 		}
36 36
 	}
37 37
 
Please login to merge, or discard this patch.
src/wordlift/vocabulary-terms/class-term-metabox.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -11,43 +11,43 @@
 block discarded – undo
11 11
 
12 12
 class Term_Metabox extends Wl_Abstract_Metabox {
13 13
 
14
-	public function __construct() {
15
-		parent::__construct();
16
-		$taxonomies = Terms_Compat::get_public_taxonomies();
17
-		foreach ( $taxonomies as $taxonomy ) {
18
-			add_action( "${taxonomy}_edit_form", array( $this, 'render_ui' ), 1 );
19
-			add_action( "edited_${taxonomy}", array( $this, 'save_field' ) );
20
-		}
21
-	}
22
-
23
-	/**
24
-	 * @param $term \WP_Term
25
-	 */
26
-	public function render_ui( $term ) {
27
-		$this->instantiate_fields( $term->term_id, Object_Type_Enum::TERM );
28
-		$this->html();
29
-		$this->enqueue_scripts_and_styles();
30
-		$plugin = \Wordlift::get_instance();
31
-
32
-		// Enqueue this scripts for sameas fields.
33
-		wp_enqueue_script(
34
-			'wl-autocomplete-select',
35
-			plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'js/dist/autocomplete-select.js',
36
-			array(),
37
-			$plugin->get_version(),
38
-			true
39
-		);
40
-
41
-		wp_enqueue_style(
42
-			'wl-autocomplete-select',
43
-			plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'js/dist/autocomplete-select.css',
44
-			array(),
45
-			$plugin->get_version()
46
-		);
47
-	}
48
-
49
-	public function save_field( $term_id ) {
50
-		$this->save_form_data( $term_id, Object_Type_Enum::TERM );
51
-	}
14
+    public function __construct() {
15
+        parent::__construct();
16
+        $taxonomies = Terms_Compat::get_public_taxonomies();
17
+        foreach ( $taxonomies as $taxonomy ) {
18
+            add_action( "${taxonomy}_edit_form", array( $this, 'render_ui' ), 1 );
19
+            add_action( "edited_${taxonomy}", array( $this, 'save_field' ) );
20
+        }
21
+    }
22
+
23
+    /**
24
+     * @param $term \WP_Term
25
+     */
26
+    public function render_ui( $term ) {
27
+        $this->instantiate_fields( $term->term_id, Object_Type_Enum::TERM );
28
+        $this->html();
29
+        $this->enqueue_scripts_and_styles();
30
+        $plugin = \Wordlift::get_instance();
31
+
32
+        // Enqueue this scripts for sameas fields.
33
+        wp_enqueue_script(
34
+            'wl-autocomplete-select',
35
+            plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'js/dist/autocomplete-select.js',
36
+            array(),
37
+            $plugin->get_version(),
38
+            true
39
+        );
40
+
41
+        wp_enqueue_style(
42
+            'wl-autocomplete-select',
43
+            plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'js/dist/autocomplete-select.css',
44
+            array(),
45
+            $plugin->get_version()
46
+        );
47
+    }
48
+
49
+    public function save_field( $term_id ) {
50
+        $this->save_form_data( $term_id, Object_Type_Enum::TERM );
51
+    }
52 52
 
53 53
 }
54 54
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -14,17 +14,17 @@  discard block
 block discarded – undo
14 14
 	public function __construct() {
15 15
 		parent::__construct();
16 16
 		$taxonomies = Terms_Compat::get_public_taxonomies();
17
-		foreach ( $taxonomies as $taxonomy ) {
18
-			add_action( "${taxonomy}_edit_form", array( $this, 'render_ui' ), 1 );
19
-			add_action( "edited_${taxonomy}", array( $this, 'save_field' ) );
17
+		foreach ($taxonomies as $taxonomy) {
18
+			add_action("${taxonomy}_edit_form", array($this, 'render_ui'), 1);
19
+			add_action("edited_${taxonomy}", array($this, 'save_field'));
20 20
 		}
21 21
 	}
22 22
 
23 23
 	/**
24 24
 	 * @param $term \WP_Term
25 25
 	 */
26
-	public function render_ui( $term ) {
27
-		$this->instantiate_fields( $term->term_id, Object_Type_Enum::TERM );
26
+	public function render_ui($term) {
27
+		$this->instantiate_fields($term->term_id, Object_Type_Enum::TERM);
28 28
 		$this->html();
29 29
 		$this->enqueue_scripts_and_styles();
30 30
 		$plugin = \Wordlift::get_instance();
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 		// Enqueue this scripts for sameas fields.
33 33
 		wp_enqueue_script(
34 34
 			'wl-autocomplete-select',
35
-			plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'js/dist/autocomplete-select.js',
35
+			plugin_dir_url(dirname(dirname(__FILE__))).'js/dist/autocomplete-select.js',
36 36
 			array(),
37 37
 			$plugin->get_version(),
38 38
 			true
@@ -40,14 +40,14 @@  discard block
 block discarded – undo
40 40
 
41 41
 		wp_enqueue_style(
42 42
 			'wl-autocomplete-select',
43
-			plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'js/dist/autocomplete-select.css',
43
+			plugin_dir_url(dirname(dirname(__FILE__))).'js/dist/autocomplete-select.css',
44 44
 			array(),
45 45
 			$plugin->get_version()
46 46
 		);
47 47
 	}
48 48
 
49
-	public function save_field( $term_id ) {
50
-		$this->save_form_data( $term_id, Object_Type_Enum::TERM );
49
+	public function save_field($term_id) {
50
+		$this->save_form_data($term_id, Object_Type_Enum::TERM);
51 51
 	}
52 52
 
53 53
 }
54 54
\ No newline at end of file
Please login to merge, or discard this patch.
src/wordlift/vocabulary-terms/class-vocabulary-terms-loader.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -12,45 +12,45 @@
 block discarded – undo
12 12
 
13 13
 
14 14
 class Vocabulary_Terms_Loader extends Default_Loader {
15
-	/**
16
-	 * @var \Wordlift_Entity_Type_Service
17
-	 */
18
-	private $entity_type_service;
19
-	/**
20
-	 * @var \Wordlift_Property_Getter
21
-	 */
22
-	private $property_getter;
23
-
24
-
25
-	/**
26
-	 * Vocabulary_Terms_Loader constructor.
27
-	 *
28
-	 * @param $entity_type_service \Wordlift_Entity_Type_Service
29
-	 * @param \Wordlift_Property_Getter $property_getter
30
-	 */
31
-	public function __construct( $entity_type_service, $property_getter ) {
32
-		parent::__construct();
33
-		$this->entity_type_service = $entity_type_service;
34
-		$this->property_getter     = $property_getter;
35
-	}
36
-
37
-
38
-	public function init_all_dependencies() {
39
-		new Entity_Type();
40
-		new Term_Metabox();
41
-		$jsonld = new Jsonld_Generator( $this->entity_type_service, $this->property_getter );
42
-		$jsonld->init();
43
-		$term_save_hook = new Term_Save();
44
-		$term_save_hook->init();
45
-	}
46
-
47
-	protected function get_feature_slug() {
48
-		return 'no-vocabulary-terms';
49
-	}
50
-
51
-	protected function get_feature_default_value() {
52
-		return false;
53
-	}
15
+    /**
16
+     * @var \Wordlift_Entity_Type_Service
17
+     */
18
+    private $entity_type_service;
19
+    /**
20
+     * @var \Wordlift_Property_Getter
21
+     */
22
+    private $property_getter;
23
+
24
+
25
+    /**
26
+     * Vocabulary_Terms_Loader constructor.
27
+     *
28
+     * @param $entity_type_service \Wordlift_Entity_Type_Service
29
+     * @param \Wordlift_Property_Getter $property_getter
30
+     */
31
+    public function __construct( $entity_type_service, $property_getter ) {
32
+        parent::__construct();
33
+        $this->entity_type_service = $entity_type_service;
34
+        $this->property_getter     = $property_getter;
35
+    }
36
+
37
+
38
+    public function init_all_dependencies() {
39
+        new Entity_Type();
40
+        new Term_Metabox();
41
+        $jsonld = new Jsonld_Generator( $this->entity_type_service, $this->property_getter );
42
+        $jsonld->init();
43
+        $term_save_hook = new Term_Save();
44
+        $term_save_hook->init();
45
+    }
46
+
47
+    protected function get_feature_slug() {
48
+        return 'no-vocabulary-terms';
49
+    }
50
+
51
+    protected function get_feature_default_value() {
52
+        return false;
53
+    }
54 54
 
55 55
 
56 56
 }
57 57
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 * @param $entity_type_service \Wordlift_Entity_Type_Service
29 29
 	 * @param \Wordlift_Property_Getter $property_getter
30 30
 	 */
31
-	public function __construct( $entity_type_service, $property_getter ) {
31
+	public function __construct($entity_type_service, $property_getter) {
32 32
 		parent::__construct();
33 33
 		$this->entity_type_service = $entity_type_service;
34 34
 		$this->property_getter     = $property_getter;
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	public function init_all_dependencies() {
39 39
 		new Entity_Type();
40 40
 		new Term_Metabox();
41
-		$jsonld = new Jsonld_Generator( $this->entity_type_service, $this->property_getter );
41
+		$jsonld = new Jsonld_Generator($this->entity_type_service, $this->property_getter);
42 42
 		$jsonld->init();
43 43
 		$term_save_hook = new Term_Save();
44 44
 		$term_save_hook->init();
Please login to merge, or discard this patch.
src/wordlift/vocabulary-terms/jsonld/class-jsonld-generator.php 2 patches
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -11,88 +11,88 @@
 block discarded – undo
11 11
 
12 12
 class Jsonld_Generator {
13 13
 
14
-	/**
15
-	 * @var \Wordlift_Entity_Type_Service
16
-	 */
17
-	private $entity_type_service;
18
-	/**
19
-	 * @var \Wordlift_Property_Getter
20
-	 */
21
-	private $property_getter;
22
-	/**
23
-	 * @var Type_Service
24
-	 */
25
-	private $term_entity_type_service;
26
-
27
-	public function __construct( $entity_type_service, $property_getter ) {
28
-		$this->entity_type_service      = $entity_type_service;
29
-		$this->property_getter          = $property_getter;
30
-		$this->term_entity_type_service = Type_Service::get_instance();
31
-	}
32
-
33
-	public function init() {
34
-		add_filter( 'wl_term_jsonld_array', array( $this, 'wl_term_jsonld_array' ), 10, 2 );
35
-	}
36
-
37
-	public function wl_term_jsonld_array( $data, $term_id ) {
38
-		$jsonld     = $data['jsonld'];
39
-		$references = $data['references'];
40
-
41
-		$term_jsonld_data = $this->get_jsonld_data_for_term( $term_id );
42
-
43
-		$term_jsonld = $term_jsonld_data['jsonld'];
44
-
45
-		$references = array_merge( $references, $term_jsonld_data['references'] );
46
-
47
-		array_unshift( $jsonld, $term_jsonld );
48
-
49
-		return array(
50
-			'jsonld'     => $jsonld,
51
-			'references' => $references
52
-		);
53
-	}
54
-
55
-	private function get_jsonld_data_for_term( $term_id ) {
56
-		$term          = get_term( $term_id );
57
-		$permalink     = get_term_link( $term );
58
-		$custom_fields = $this->entity_type_service->get_custom_fields_for_term( $term_id );
59
-		$term          = get_term( $term_id );
60
-		$jsonld        = array(
61
-			'@context'    => 'http://schema.org',
62
-			'name'        => $term->name,
63
-			'@type'       => $this->term_entity_type_service->get_entity_types_labels( $term_id ),
64
-			'@id'         => wl_get_term_entity_uri( $term_id ),
65
-			'description' => $term->description,
66
-		);
67
-
68
-		if ( ! $custom_fields || ! is_array( $custom_fields ) ) {
69
-			return $jsonld;
70
-		}
71
-
72
-		foreach ( $custom_fields as $key => $value ) {
73
-			$name  = $this->relative_to_schema_context( $value['predicate'] );
74
-			$value = $this->property_getter->get( $term_id, $key, Object_Type_Enum::TERM );
75
-			if ( $value ) {
76
-				$jsonld[ $name ] = $value;
77
-			}
78
-		}
79
-
80
-		if ( $permalink ) {
81
-			$jsonld['url']              = $permalink;
82
-			$jsonld['mainEntityOfPage'] = $permalink;
83
-		}
84
-
85
-		return apply_filters( 'wl_no_vocabulary_term_jsonld_array', array(
86
-			'jsonld'     => $jsonld,
87
-			'references' => array()
88
-		), $term_id );
89
-
90
-
91
-	}
92
-
93
-
94
-	private function relative_to_schema_context( $predicate ) {
95
-		return str_replace( 'http://schema.org/', '', $predicate );
96
-	}
14
+    /**
15
+     * @var \Wordlift_Entity_Type_Service
16
+     */
17
+    private $entity_type_service;
18
+    /**
19
+     * @var \Wordlift_Property_Getter
20
+     */
21
+    private $property_getter;
22
+    /**
23
+     * @var Type_Service
24
+     */
25
+    private $term_entity_type_service;
26
+
27
+    public function __construct( $entity_type_service, $property_getter ) {
28
+        $this->entity_type_service      = $entity_type_service;
29
+        $this->property_getter          = $property_getter;
30
+        $this->term_entity_type_service = Type_Service::get_instance();
31
+    }
32
+
33
+    public function init() {
34
+        add_filter( 'wl_term_jsonld_array', array( $this, 'wl_term_jsonld_array' ), 10, 2 );
35
+    }
36
+
37
+    public function wl_term_jsonld_array( $data, $term_id ) {
38
+        $jsonld     = $data['jsonld'];
39
+        $references = $data['references'];
40
+
41
+        $term_jsonld_data = $this->get_jsonld_data_for_term( $term_id );
42
+
43
+        $term_jsonld = $term_jsonld_data['jsonld'];
44
+
45
+        $references = array_merge( $references, $term_jsonld_data['references'] );
46
+
47
+        array_unshift( $jsonld, $term_jsonld );
48
+
49
+        return array(
50
+            'jsonld'     => $jsonld,
51
+            'references' => $references
52
+        );
53
+    }
54
+
55
+    private function get_jsonld_data_for_term( $term_id ) {
56
+        $term          = get_term( $term_id );
57
+        $permalink     = get_term_link( $term );
58
+        $custom_fields = $this->entity_type_service->get_custom_fields_for_term( $term_id );
59
+        $term          = get_term( $term_id );
60
+        $jsonld        = array(
61
+            '@context'    => 'http://schema.org',
62
+            'name'        => $term->name,
63
+            '@type'       => $this->term_entity_type_service->get_entity_types_labels( $term_id ),
64
+            '@id'         => wl_get_term_entity_uri( $term_id ),
65
+            'description' => $term->description,
66
+        );
67
+
68
+        if ( ! $custom_fields || ! is_array( $custom_fields ) ) {
69
+            return $jsonld;
70
+        }
71
+
72
+        foreach ( $custom_fields as $key => $value ) {
73
+            $name  = $this->relative_to_schema_context( $value['predicate'] );
74
+            $value = $this->property_getter->get( $term_id, $key, Object_Type_Enum::TERM );
75
+            if ( $value ) {
76
+                $jsonld[ $name ] = $value;
77
+            }
78
+        }
79
+
80
+        if ( $permalink ) {
81
+            $jsonld['url']              = $permalink;
82
+            $jsonld['mainEntityOfPage'] = $permalink;
83
+        }
84
+
85
+        return apply_filters( 'wl_no_vocabulary_term_jsonld_array', array(
86
+            'jsonld'     => $jsonld,
87
+            'references' => array()
88
+        ), $term_id );
89
+
90
+
91
+    }
92
+
93
+
94
+    private function relative_to_schema_context( $predicate ) {
95
+        return str_replace( 'http://schema.org/', '', $predicate );
96
+    }
97 97
 
98 98
 }
99 99
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -24,27 +24,27 @@  discard block
 block discarded – undo
24 24
 	 */
25 25
 	private $term_entity_type_service;
26 26
 
27
-	public function __construct( $entity_type_service, $property_getter ) {
27
+	public function __construct($entity_type_service, $property_getter) {
28 28
 		$this->entity_type_service      = $entity_type_service;
29 29
 		$this->property_getter          = $property_getter;
30 30
 		$this->term_entity_type_service = Type_Service::get_instance();
31 31
 	}
32 32
 
33 33
 	public function init() {
34
-		add_filter( 'wl_term_jsonld_array', array( $this, 'wl_term_jsonld_array' ), 10, 2 );
34
+		add_filter('wl_term_jsonld_array', array($this, 'wl_term_jsonld_array'), 10, 2);
35 35
 	}
36 36
 
37
-	public function wl_term_jsonld_array( $data, $term_id ) {
37
+	public function wl_term_jsonld_array($data, $term_id) {
38 38
 		$jsonld     = $data['jsonld'];
39 39
 		$references = $data['references'];
40 40
 
41
-		$term_jsonld_data = $this->get_jsonld_data_for_term( $term_id );
41
+		$term_jsonld_data = $this->get_jsonld_data_for_term($term_id);
42 42
 
43 43
 		$term_jsonld = $term_jsonld_data['jsonld'];
44 44
 
45
-		$references = array_merge( $references, $term_jsonld_data['references'] );
45
+		$references = array_merge($references, $term_jsonld_data['references']);
46 46
 
47
-		array_unshift( $jsonld, $term_jsonld );
47
+		array_unshift($jsonld, $term_jsonld);
48 48
 
49 49
 		return array(
50 50
 			'jsonld'     => $jsonld,
@@ -52,47 +52,47 @@  discard block
 block discarded – undo
52 52
 		);
53 53
 	}
54 54
 
55
-	private function get_jsonld_data_for_term( $term_id ) {
56
-		$term          = get_term( $term_id );
57
-		$permalink     = get_term_link( $term );
58
-		$custom_fields = $this->entity_type_service->get_custom_fields_for_term( $term_id );
59
-		$term          = get_term( $term_id );
55
+	private function get_jsonld_data_for_term($term_id) {
56
+		$term          = get_term($term_id);
57
+		$permalink     = get_term_link($term);
58
+		$custom_fields = $this->entity_type_service->get_custom_fields_for_term($term_id);
59
+		$term          = get_term($term_id);
60 60
 		$jsonld        = array(
61 61
 			'@context'    => 'http://schema.org',
62 62
 			'name'        => $term->name,
63
-			'@type'       => $this->term_entity_type_service->get_entity_types_labels( $term_id ),
64
-			'@id'         => wl_get_term_entity_uri( $term_id ),
63
+			'@type'       => $this->term_entity_type_service->get_entity_types_labels($term_id),
64
+			'@id'         => wl_get_term_entity_uri($term_id),
65 65
 			'description' => $term->description,
66 66
 		);
67 67
 
68
-		if ( ! $custom_fields || ! is_array( $custom_fields ) ) {
68
+		if ( ! $custom_fields || ! is_array($custom_fields)) {
69 69
 			return $jsonld;
70 70
 		}
71 71
 
72
-		foreach ( $custom_fields as $key => $value ) {
73
-			$name  = $this->relative_to_schema_context( $value['predicate'] );
74
-			$value = $this->property_getter->get( $term_id, $key, Object_Type_Enum::TERM );
75
-			if ( $value ) {
76
-				$jsonld[ $name ] = $value;
72
+		foreach ($custom_fields as $key => $value) {
73
+			$name  = $this->relative_to_schema_context($value['predicate']);
74
+			$value = $this->property_getter->get($term_id, $key, Object_Type_Enum::TERM);
75
+			if ($value) {
76
+				$jsonld[$name] = $value;
77 77
 			}
78 78
 		}
79 79
 
80
-		if ( $permalink ) {
80
+		if ($permalink) {
81 81
 			$jsonld['url']              = $permalink;
82 82
 			$jsonld['mainEntityOfPage'] = $permalink;
83 83
 		}
84 84
 
85
-		return apply_filters( 'wl_no_vocabulary_term_jsonld_array', array(
85
+		return apply_filters('wl_no_vocabulary_term_jsonld_array', array(
86 86
 			'jsonld'     => $jsonld,
87 87
 			'references' => array()
88
-		), $term_id );
88
+		), $term_id);
89 89
 
90 90
 
91 91
 	}
92 92
 
93 93
 
94
-	private function relative_to_schema_context( $predicate ) {
95
-		return str_replace( 'http://schema.org/', '', $predicate );
94
+	private function relative_to_schema_context($predicate) {
95
+		return str_replace('http://schema.org/', '', $predicate);
96 96
 	}
97 97
 
98 98
 }
99 99
\ No newline at end of file
Please login to merge, or discard this patch.
src/wordlift/class-object-type-enum.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -4,13 +4,13 @@
 block discarded – undo
4 4
 
5 5
 class Object_Type_Enum {
6 6
 
7
-	const POST = 0;
8
-	const TERM = 1;
9
-	const HOMEPAGE = 2;
10
-	const USER = 3;
7
+    const POST = 0;
8
+    const TERM = 1;
9
+    const HOMEPAGE = 2;
10
+    const USER = 3;
11 11
 
12
-	// Enum constant to represent currently unknown
13
-	// value.
14
-	const UNKNOWN = 4;
12
+    // Enum constant to represent currently unknown
13
+    // value.
14
+    const UNKNOWN = 4;
15 15
 
16 16
 }
Please login to merge, or discard this patch.
src/wordlift/relation/class-post-relation-service.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -15,51 +15,51 @@
 block discarded – undo
15 15
 use Wordlift\Relation\Types\Post_Relation;
16 16
 
17 17
 class Post_Relation_Service extends Singleton implements Relation_Service_Interface {
18
-	/**
19
-	 * @var \Wordlift_Relation_Service
20
-	 */
21
-	private $legacy_post_relation_service;
22
-	/**
23
-	 * @var \Wordlift_Entity_Uri_Service
24
-	 */
25
-	private $entity_uri_service;
26
-	/**
27
-	 * @var \Wordlift_Entity_Service
28
-	 */
29
-	private $entity_service;
18
+    /**
19
+     * @var \Wordlift_Relation_Service
20
+     */
21
+    private $legacy_post_relation_service;
22
+    /**
23
+     * @var \Wordlift_Entity_Uri_Service
24
+     */
25
+    private $entity_uri_service;
26
+    /**
27
+     * @var \Wordlift_Entity_Service
28
+     */
29
+    private $entity_service;
30 30
 
31 31
 
32
-	/**
33
-	 * @return Post_Relation_Service
34
-	 */
35
-	public static function get_instance() {
36
-		return parent::get_instance();
37
-	}
32
+    /**
33
+     * @return Post_Relation_Service
34
+     */
35
+    public static function get_instance() {
36
+        return parent::get_instance();
37
+    }
38 38
 
39
-	public function __construct() {
40
-		parent::__construct();
41
-		$this->legacy_post_relation_service = \Wordlift_Relation_Service::get_instance();
42
-		$this->entity_uri_service    = \Wordlift_Entity_Uri_Service::get_instance();
43
-		$this->entity_service        = \Wordlift_Entity_Service::get_instance();
44
-	}
39
+    public function __construct() {
40
+        parent::__construct();
41
+        $this->legacy_post_relation_service = \Wordlift_Relation_Service::get_instance();
42
+        $this->entity_uri_service    = \Wordlift_Entity_Uri_Service::get_instance();
43
+        $this->entity_service        = \Wordlift_Entity_Service::get_instance();
44
+    }
45 45
 
46 46
 
47
-	public function get_references( $subject_id, $subject_type ) {
48
-		$post_ids        = $this->legacy_post_relation_service->get_objects( $subject_id, 'ids' );
49
-		return array_map( function ( $post_id ) {
50
-			return new Post_Reference( $post_id );
51
-		}, $post_ids );
52
-	}
47
+    public function get_references( $subject_id, $subject_type ) {
48
+        $post_ids        = $this->legacy_post_relation_service->get_objects( $subject_id, 'ids' );
49
+        return array_map( function ( $post_id ) {
50
+            return new Post_Reference( $post_id );
51
+        }, $post_ids );
52
+    }
53 53
 
54
-	public function get_relations_from_content( $content, $subject_type ) {
55
-		$entity_uris =  Object_Relation_Service::get_entity_uris( $content );
56
-		$that = $this;
57
-		return array_map( function ( $entity_uri ) use ( $subject_type, $that ) {
58
-			$entity =  $that->entity_uri_service->get_entity( $entity_uri );
59
-			if (  ! $entity ) {
60
-				return false;
61
-			}
62
-			return new Post_Relation( $entity->ID, $that->entity_service->get_classification_scope_for( $entity->ID ), $subject_type );
63
-		}, $entity_uris );
64
-	}
54
+    public function get_relations_from_content( $content, $subject_type ) {
55
+        $entity_uris =  Object_Relation_Service::get_entity_uris( $content );
56
+        $that = $this;
57
+        return array_map( function ( $entity_uri ) use ( $subject_type, $that ) {
58
+            $entity =  $that->entity_uri_service->get_entity( $entity_uri );
59
+            if (  ! $entity ) {
60
+                return false;
61
+            }
62
+            return new Post_Relation( $entity->ID, $that->entity_service->get_classification_scope_for( $entity->ID ), $subject_type );
63
+        }, $entity_uris );
64
+    }
65 65
 }
66 66
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -44,22 +44,22 @@
 block discarded – undo
44 44
 	}
45 45
 
46 46
 
47
-	public function get_references( $subject_id, $subject_type ) {
48
-		$post_ids        = $this->legacy_post_relation_service->get_objects( $subject_id, 'ids' );
49
-		return array_map( function ( $post_id ) {
50
-			return new Post_Reference( $post_id );
51
-		}, $post_ids );
47
+	public function get_references($subject_id, $subject_type) {
48
+		$post_ids = $this->legacy_post_relation_service->get_objects($subject_id, 'ids');
49
+		return array_map(function($post_id) {
50
+			return new Post_Reference($post_id);
51
+		}, $post_ids);
52 52
 	}
53 53
 
54
-	public function get_relations_from_content( $content, $subject_type ) {
55
-		$entity_uris =  Object_Relation_Service::get_entity_uris( $content );
54
+	public function get_relations_from_content($content, $subject_type) {
55
+		$entity_uris = Object_Relation_Service::get_entity_uris($content);
56 56
 		$that = $this;
57
-		return array_map( function ( $entity_uri ) use ( $subject_type, $that ) {
58
-			$entity =  $that->entity_uri_service->get_entity( $entity_uri );
59
-			if (  ! $entity ) {
57
+		return array_map(function($entity_uri) use ($subject_type, $that) {
58
+			$entity = $that->entity_uri_service->get_entity($entity_uri);
59
+			if ( ! $entity) {
60 60
 				return false;
61 61
 			}
62
-			return new Post_Relation( $entity->ID, $that->entity_service->get_classification_scope_for( $entity->ID ), $subject_type );
63
-		}, $entity_uris );
62
+			return new Post_Relation($entity->ID, $that->entity_service->get_classification_scope_for($entity->ID), $subject_type);
63
+		}, $entity_uris);
64 64
 	}
65 65
 }
66 66
\ No newline at end of file
Please login to merge, or discard this patch.
src/wordlift/relation/class-relation-service-interface.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -17,21 +17,21 @@
 block discarded – undo
17 17
 
18 18
 interface  Relation_Service_Interface {
19 19
 
20
-	/**
21
-	 * @param $subject_id int
22
-	 * @param int $subject_type {@link Object_Type_Enum}
23
-	 * @return array<Reference>
24
-	 */
25
-	public function get_references( $subject_id, $subject_type );
20
+    /**
21
+     * @param $subject_id int
22
+     * @param int $subject_type {@link Object_Type_Enum}
23
+     * @return array<Reference>
24
+     */
25
+    public function get_references( $subject_id, $subject_type );
26 26
 
27 27
 
28
-	/**
29
-	 * @param $content string
30
-	 * @param int $subject_type {@link Object_Type_Enum}
31
-	 * @return array<Relation>
32
-	 * Extracts the relations from the post content.
33
-	 */
34
-	public function get_relations_from_content( $content, $subject_type );
28
+    /**
29
+     * @param $content string
30
+     * @param int $subject_type {@link Object_Type_Enum}
31
+     * @return array<Relation>
32
+     * Extracts the relations from the post content.
33
+     */
34
+    public function get_relations_from_content( $content, $subject_type );
35 35
 
36 36
 
37 37
 }
38 38
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 * @param int $subject_type {@link Object_Type_Enum}
23 23
 	 * @return array<Reference>
24 24
 	 */
25
-	public function get_references( $subject_id, $subject_type );
25
+	public function get_references($subject_id, $subject_type);
26 26
 
27 27
 
28 28
 	/**
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 * @return array<Relation>
32 32
 	 * Extracts the relations from the post content.
33 33
 	 */
34
-	public function get_relations_from_content( $content, $subject_type );
34
+	public function get_relations_from_content($content, $subject_type);
35 35
 
36 36
 
37 37
 }
38 38
\ No newline at end of file
Please login to merge, or discard this patch.
src/wordlift/relation/class-object-relation-service.php 2 patches
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -17,72 +17,72 @@
 block discarded – undo
17 17
 
18 18
 class Object_Relation_Service extends Singleton implements Relation_Service_Interface {
19 19
 
20
-	/**
21
-	 * @var \Wordlift_Relation_Service
22
-	 */
23
-	private $post_relation_service;
24
-	/**
25
-	 * @var Term_Relation_Service
26
-	 */
27
-	private $term_relation_service;
28
-
29
-	/**
30
-	 * @var \Wordlift_Log_Service
31
-	 */
32
-	private $log;
33
-
34
-	public function __construct() {
35
-		parent::__construct();
36
-		$this->post_relation_service = Post_Relation_Service::get_instance();
37
-		$this->term_relation_service = Term_Relation_Service::get_instance();
38
-		$this->log                   = \Wordlift_Log_Service::get_logger( get_class() );
39
-	}
40
-
41
-	/**
42
-	 * @return Object_Relation_Service
43
-	 */
44
-	public static function get_instance() {
45
-		return parent::get_instance();
46
-	}
47
-
48
-	/**
49
-	 * @param $subject_id int
50
-	 *
51
-	 * @return array<Reference>
52
-	 */
53
-	public function get_references( $subject_id, $subject_type ) {
54
-		$post_references = $this->post_relation_service->get_references( $subject_id, $subject_type );
55
-		$term_references = $this->term_relation_service->get_references( $subject_id, $subject_type );
56
-
57
-		return array_merge( $post_references, $term_references );
58
-	}
59
-
60
-
61
-	public function get_relations_from_content( $content, $subject_type ) {
62
-		$entity_uris = array_unique( self::get_entity_uris( $content ) );
63
-		$this->log->debug( "Found " . var_export( $entity_uris, true ) . " by object relation service" );
64
-		$post_relations = $this->post_relation_service->get_relations_from_content( $content, $subject_type );
65
-		$term_relations = $this->term_relation_service->get_relations_from_content( $content, $subject_type );
66
-		return array_filter( array_merge( $post_relations, $term_relations) );
67
-	}
68
-
69
-
70
-	public static function get_entity_uris( $content ) {
71
-		// Remove quote escapes.
72
-		$content = str_replace( '\\"', '"', $content );
73
-
74
-		// Match all itemid attributes.
75
-		$pattern = '/<\w+[^>]*\sitemid="([^"]+)"[^>]*>/im';
76
-
77
-		// Remove the pattern while it is found (match nested annotations).
78
-		$matches = array();
79
-
80
-		// In case of errors, return an empty array.
81
-		if ( false === preg_match_all( $pattern, $content, $matches ) ) {
82
-
83
-			return array();
84
-		}
85
-
86
-		return $matches[1];
87
-	}
20
+    /**
21
+     * @var \Wordlift_Relation_Service
22
+     */
23
+    private $post_relation_service;
24
+    /**
25
+     * @var Term_Relation_Service
26
+     */
27
+    private $term_relation_service;
28
+
29
+    /**
30
+     * @var \Wordlift_Log_Service
31
+     */
32
+    private $log;
33
+
34
+    public function __construct() {
35
+        parent::__construct();
36
+        $this->post_relation_service = Post_Relation_Service::get_instance();
37
+        $this->term_relation_service = Term_Relation_Service::get_instance();
38
+        $this->log                   = \Wordlift_Log_Service::get_logger( get_class() );
39
+    }
40
+
41
+    /**
42
+     * @return Object_Relation_Service
43
+     */
44
+    public static function get_instance() {
45
+        return parent::get_instance();
46
+    }
47
+
48
+    /**
49
+     * @param $subject_id int
50
+     *
51
+     * @return array<Reference>
52
+     */
53
+    public function get_references( $subject_id, $subject_type ) {
54
+        $post_references = $this->post_relation_service->get_references( $subject_id, $subject_type );
55
+        $term_references = $this->term_relation_service->get_references( $subject_id, $subject_type );
56
+
57
+        return array_merge( $post_references, $term_references );
58
+    }
59
+
60
+
61
+    public function get_relations_from_content( $content, $subject_type ) {
62
+        $entity_uris = array_unique( self::get_entity_uris( $content ) );
63
+        $this->log->debug( "Found " . var_export( $entity_uris, true ) . " by object relation service" );
64
+        $post_relations = $this->post_relation_service->get_relations_from_content( $content, $subject_type );
65
+        $term_relations = $this->term_relation_service->get_relations_from_content( $content, $subject_type );
66
+        return array_filter( array_merge( $post_relations, $term_relations) );
67
+    }
68
+
69
+
70
+    public static function get_entity_uris( $content ) {
71
+        // Remove quote escapes.
72
+        $content = str_replace( '\\"', '"', $content );
73
+
74
+        // Match all itemid attributes.
75
+        $pattern = '/<\w+[^>]*\sitemid="([^"]+)"[^>]*>/im';
76
+
77
+        // Remove the pattern while it is found (match nested annotations).
78
+        $matches = array();
79
+
80
+        // In case of errors, return an empty array.
81
+        if ( false === preg_match_all( $pattern, $content, $matches ) ) {
82
+
83
+            return array();
84
+        }
85
+
86
+        return $matches[1];
87
+    }
88 88
 }
89 89
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 		parent::__construct();
36 36
 		$this->post_relation_service = Post_Relation_Service::get_instance();
37 37
 		$this->term_relation_service = Term_Relation_Service::get_instance();
38
-		$this->log                   = \Wordlift_Log_Service::get_logger( get_class() );
38
+		$this->log                   = \Wordlift_Log_Service::get_logger(get_class());
39 39
 	}
40 40
 
41 41
 	/**
@@ -50,26 +50,26 @@  discard block
 block discarded – undo
50 50
 	 *
51 51
 	 * @return array<Reference>
52 52
 	 */
53
-	public function get_references( $subject_id, $subject_type ) {
54
-		$post_references = $this->post_relation_service->get_references( $subject_id, $subject_type );
55
-		$term_references = $this->term_relation_service->get_references( $subject_id, $subject_type );
53
+	public function get_references($subject_id, $subject_type) {
54
+		$post_references = $this->post_relation_service->get_references($subject_id, $subject_type);
55
+		$term_references = $this->term_relation_service->get_references($subject_id, $subject_type);
56 56
 
57
-		return array_merge( $post_references, $term_references );
57
+		return array_merge($post_references, $term_references);
58 58
 	}
59 59
 
60 60
 
61
-	public function get_relations_from_content( $content, $subject_type ) {
62
-		$entity_uris = array_unique( self::get_entity_uris( $content ) );
63
-		$this->log->debug( "Found " . var_export( $entity_uris, true ) . " by object relation service" );
64
-		$post_relations = $this->post_relation_service->get_relations_from_content( $content, $subject_type );
65
-		$term_relations = $this->term_relation_service->get_relations_from_content( $content, $subject_type );
66
-		return array_filter( array_merge( $post_relations, $term_relations) );
61
+	public function get_relations_from_content($content, $subject_type) {
62
+		$entity_uris = array_unique(self::get_entity_uris($content));
63
+		$this->log->debug("Found ".var_export($entity_uris, true)." by object relation service");
64
+		$post_relations = $this->post_relation_service->get_relations_from_content($content, $subject_type);
65
+		$term_relations = $this->term_relation_service->get_relations_from_content($content, $subject_type);
66
+		return array_filter(array_merge($post_relations, $term_relations));
67 67
 	}
68 68
 
69 69
 
70
-	public static function get_entity_uris( $content ) {
70
+	public static function get_entity_uris($content) {
71 71
 		// Remove quote escapes.
72
-		$content = str_replace( '\\"', '"', $content );
72
+		$content = str_replace('\\"', '"', $content);
73 73
 
74 74
 		// Match all itemid attributes.
75 75
 		$pattern = '/<\w+[^>]*\sitemid="([^"]+)"[^>]*>/im';
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 		$matches = array();
79 79
 
80 80
 		// In case of errors, return an empty array.
81
-		if ( false === preg_match_all( $pattern, $content, $matches ) ) {
81
+		if (false === preg_match_all($pattern, $content, $matches)) {
82 82
 
83 83
 			return array();
84 84
 		}
Please login to merge, or discard this patch.