PluginProbe
404 Solution / 4.3.0
404 Solution v4.3.0
4.3.5 4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 4.2.0 4.1.19 4.1.18 4.1.17 4.1.16 4.1.15 4.1.13 4.1.12 4.1.11 4.1.10 4.1.9 4.1.8 4.1.7 4.1.6 4.1.5 4.1.4 4.1.3 trunk 2.30.0 All 109 releases
404-solution / includes / bootstrap / MatchingEngineServiceRegistration.php

MatchingEngineServiceRegistration.php in 404 Solution 4.3.0, at includes/bootstrap/MatchingEngineServiceRegistration.php

75 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH')) {
4 exit;
5 }
6
7 /**
8 * Registers redirect matching engines and the filterable engine list.
9 */
10 class ABJ_404_Solution_MatchingEngineServiceRegistration {
11
12 /**
13 * @param ABJ_404_Solution_ServiceContainer $container
14 * @return void
15 */
16 public static function register($container): void {
17 $container->set('engine_slug', function($c) {
18 return new ABJ_404_Solution_SlugMatchingEngine($c->get('spell_checker'));
19 });
20
21 $container->set('engine_url_fix', function($c) {
22 return new ABJ_404_Solution_UrlFixEngine(
23 $c->get('spell_checker'),
24 $c->get('functions'),
25 $c->get('logging')
26 );
27 });
28
29 $container->set('engine_title', function($c) {
30 return new ABJ_404_Solution_TitleMatchingEngine(
31 $c->get('content_repository'),
32 $c->get('functions'),
33 $c->get('logging')
34 );
35 });
36
37 $container->set('engine_category_tag', function($c) {
38 return new ABJ_404_Solution_CategoryTagMatchingEngine(
39 $c->get('content_repository'),
40 $c->get('functions'),
41 $c->get('logging'),
42 $c->get('term_candidate_source')
43 );
44 });
45
46 $container->set('engine_content', function($c) {
47 return new ABJ_404_Solution_ContentMatchingEngine(
48 $c->get('content_repository'),
49 $c->get('functions'),
50 $c->get('logging')
51 );
52 });
53
54 $container->set('engine_spelling', function($c) {
55 return new ABJ_404_Solution_SpellingMatchingEngine($c->get('spell_checker'));
56 });
57
58 $container->set('engine_archive_fallback', function($c) {
59 return new ABJ_404_Solution_ArchiveFallbackEngine(
60 $c->get('functions'),
61 $c->get('logging')
62 );
63 });
64
65 $container->set('matching_engines', function($c) {
66 $engines = [$c->get('engine_slug'), $c->get('engine_url_fix'), $c->get('engine_title'), $c->get('engine_category_tag'), $c->get('engine_content'), $c->get('engine_spelling'), $c->get('engine_archive_fallback')];
67 if (function_exists('apply_filters')) {
68 $filtered = apply_filters('abj404_matching_engines', $engines);
69 $engines = is_array($filtered) ? $filtered : [];
70 }
71 return $engines;
72 });
73 }
74 }
75