Completed
Pull Request — develop (#1328)
by Naveen
03:12
created

Vocabulary_Loader::init_vocabulary()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 50

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 50
rs 9.0909
c 0
b 0
f 0
1
<?php
2
3
namespace Wordlift\Vocabulary;
4
5
use Wordlift\Api\Default_Api_Service;
6
use Wordlift\Api\User_Agent;
7
use Wordlift\Vocabulary\Api\Background_Analysis_Endpoint;
8
use Wordlift\Vocabulary\Api\Entity_Rest_Endpoint;
9
use Wordlift\Vocabulary\Api\Reconcile_Progress_Endpoint;
10
use Wordlift\Vocabulary\Api\Tag_Rest_Endpoint;
11
use Wordlift\Vocabulary\Dashboard\Term_Matches_Widget;
12
use Wordlift\Vocabulary\Data\Term_Count\Cached_Term_count_Manager;
13
use Wordlift\Vocabulary\Data\Term_Count\Term_Count_Factory;
14
use Wordlift\Vocabulary\Data\Term_Data\Term_Data_Factory;
15
use Wordlift\Vocabulary\Hooks\Tag_Created_Hook;
16
use Wordlift\Vocabulary\Hooks\Term_Page_Hook;
17
use Wordlift\Vocabulary\Jsonld\Post_Jsonld;
18
use Wordlift\Vocabulary\Pages\Match_Terms;
19
20
class Vocabulary_Loader {
21
22
	public function init_vocabulary() {
23
24
		$configuration_service = \Wordlift_Configuration_Service::get_instance();
25
26
		$api_service = new Default_Api_Service(
27
			apply_filters( 'wl_api_base_url', 'https://api.wordlift.io' ),
28
			60,
29
			User_Agent::get_user_agent(),
30
			$configuration_service->get_key()
31
		);
32
33
		$cache_service    = new Options_Cache( "wordlift-cmkg" );
34
		$analysis_service = new Analysis_Service( $api_service, $cache_service );
35
36
		$term_data_factory = new Term_Data_Factory( $analysis_service );
37
38
		$tag_rest_endpoint = new Tag_Rest_Endpoint( $term_data_factory );
39
		$tag_rest_endpoint->register_routes();
40
41
		$entity_rest_endpoint = new Entity_Rest_Endpoint();
42
		$entity_rest_endpoint->register_routes();
43
44
		$post_jsonld = new Post_Jsonld();
45
		$post_jsonld->enhance_post_jsonld();
46
47
		$term_count = Term_Count_Factory::get_instance( Term_Count_Factory::CACHED_TERM_COUNT );
48
		new Match_Terms( $term_count );
49
50
		$analysis_background_service = new Analysis_Background_Service( $analysis_service );
51
52
53
		new Tag_Created_Hook( $analysis_background_service );
54
55
		new Background_Analysis_Endpoint( $analysis_background_service, $cache_service );
56
57
		$reconcile_progress_endpoint = new Reconcile_Progress_Endpoint();
58
		$reconcile_progress_endpoint->register_routes();
59
60
61
		$term_page_hook = new Term_Page_Hook( $term_data_factory );
62
		$term_page_hook->connect_hook();
63
64
		$dashboard_widget = new Term_Matches_Widget( $term_count );
65
		$dashboard_widget->connect_hook();
66
67
		$cached_term_count_manager = new Cached_Term_count_Manager();
68
		$cached_term_count_manager->connect_hook();
69
70
71
	}
72
73
}
74
75
76