-
Notifications
You must be signed in to change notification settings - Fork 2
/
bootstrap.php
74 lines (53 loc) · 3.48 KB
/
bootstrap.php
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
67
68
69
70
71
72
73
74
<?php
namespace NewsParserPlugin;
use NewsParserPlugin\Core\ScriptLoadingManager;
function news_parser_init(){
// Dependency Injection container initialization
$container=new \ContainerBuilder\DI();
$container->addDefinitions(NEWS_PARSER_PLUGIN_DIR.'inc/Config/di-config.php');
//$container=$container_builder->build();
// Load script, style, and global variable configurations
//$scripts_config= include NEWS_PARSER_PLUGIN_DIR.'inc/Config/scripts-config-dev.php';
//$styles_config= include NEWS_PARSER_PLUGIN_DIR.'inc/Config/styles-config-dev.php';
$scripts_config= include NEWS_PARSER_PLUGIN_DIR.'inc/Config/scripts-config.php';
$styles_config= include NEWS_PARSER_PLUGIN_DIR.'inc/Config/styles-config.php';
$global_variables_config= include NEWS_PARSER_PLUGIN_DIR.'inc/Config/global-variables-config.php';
$scripts_translation_config= include NEWS_PARSER_PLUGIN_DIR.'inc/Config/scripts-translation-config.php';
$app=Core\App::start($container);
// Initialize the ScriptLoadingManager
$loading_manager=ScriptLoadingManager::getInstance($container->get(\NewsParserPlugin\Menu\Admin\MenuPage::class),$container->get(\NewsParserPlugin\Utils\MenuConfig::class));
$loading_manager->setScriptsConfig($scripts_config);
$loading_manager->setStylesConfig($styles_config);
$loading_manager->setGlobalVariablesConfig($global_variables_config);
$loading_manager->setScriptsTranslationConfig($scripts_translation_config);
$loading_manager->init();
// Set up modifiers middleware for html parser
$modifiers=array(
new Modifiers\RemoveLineBreaks(),
new Modifiers\ReplaceRelativePathWithAbsolute(),
new Modifiers\ImagePrepare()
);
$app->middleware->add('htmlRaw:parse',$modifiers);
// Event listeners
$app->event->on('media:create',array(Controller\MediaController::class,'create'));
$app->event->on('template:create',array(Controller\TemplateControllerWithUserInfo::class,'create'));
$app->event->on('template:get',array(Controller\TemplateControllerWithUserInfo::class,'get'));
$app->event->on('template:delete',array(Controller\TemplateControllerWithUserInfo::class,'delete'));
$app->event->on('template.keys:get',array(Controller\TemplateControllerWithUserInfo::class,'templateKeys'));
$app->event->on('cron:create',array(Controller\CronController::class,'create'));
$app->event->on('cron:delete',array(Controller\CronController::class,'delete'));
$app->event->on('cron:get',array(Controller\CronController::class,'get'));
$app->event->on('list:get',array(Controller\ListController::class,'get'));
$app->event->on('html:get',array(Controller\VisualConstructorController::class,'get'));
$app->event->on('post:create',array(Controller\PostControllerUserID::class,'create'));
// Add cron action
add_action(NEWS_PARSER_CRON_ACTION_PREFIX.'hourly',array($app->cronTaskController,'cronTaskCallback'));
add_action(NEWS_PARSER_CRON_ACTION_PREFIX.'twicedaily',array($app->cronTaskController,'cronTaskCallback'));
add_action(NEWS_PARSER_CRON_ACTION_PREFIX.'daily',array($app->cronTaskController,'cronTaskCallback'));
add_action(NEWS_PARSER_CRON_ACTION_PREFIX.'weekly',array($app->cronTaskController,'cronTaskCallback'));
// Add WP_CLI commands
if ( defined( 'WP_CLI' ) && WP_CLI ) {
$invoke_autopilot=new \NewsParserPlugin\CLI\InvokeAutopilot($app->cronTaskController);
\WP_CLI::add_command( 'autopilot', array($invoke_autopilot,'commandCallback'));
}
}