wpml-st-script-translations-hooks-factory.php
1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
use WPML\ST\JED\Hooks\Sync;
use WPML\ST\TranslationFile\Sync\FileSync;
use function WPML\Container\make;
use WPML\ST\TranslationFile\UpdateHooks;
class WPML_ST_Script_Translations_Hooks_Factory implements IWPML_Backend_Action_Loader, IWPML_Frontend_Action_Loader {
/**
* Create hooks.
*
* @return array|IWPML_Action
* @throws \WPML\Auryn\InjectionException Auryn Exception.
*/
public function create() {
$hooks = array();
$jed_file_manager = make(
WPML_ST_JED_File_Manager::class,
[ ':builder' => make( WPML_ST_JED_File_Builder::class ) ]
);
$hooks['update'] = $this->get_update_hooks( $jed_file_manager );
if ( ! wpml_is_ajax() && ! wpml_is_rest_request() ) {
$hooks['filtering'] = $this->get_filtering_hooks( $jed_file_manager );
}
if ( WPML\ST\TranslationFile\Hooks::useFileSynchronization() ) {
$hooks['sync'] = make(
Sync::class,
[
':fileSync' => make( FileSync::class, [ ':manager' => $jed_file_manager ] ),
':manager' => $jed_file_manager,
]
);
}
return $hooks;
}
/**
* @param WPML_ST_JED_File_Manager $jed_file_manager
*
* @return UpdateHooks
*/
private function get_update_hooks( $jed_file_manager ) {
return make(
UpdateHooks::class,
[ ':file_manager' => $jed_file_manager ]
);
}
/**
* @param WPML_ST_JED_File_Manager $jed_file_manager
*
* @return WPML_ST_Script_Translations_Hooks
*/
private function get_filtering_hooks( $jed_file_manager ) {
return make(
WPML_ST_Script_Translations_Hooks::class,
[ ':jed_file_manager' => $jed_file_manager ]
);
}
}