Completed
Branch EDTR/master (6a4cc7)
by
unknown
43:17 queued 35:24
created

ShortcodeRequests::matchesCurrentRequest()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace EventEspresso\core\domain\entities\routing\handlers\frontend;
4
5
use EE_Config;
6
use EE_Dependency_Map;
7
use EventEspresso\core\domain\entities\routing\handlers\Route;
8
9
/**
10
 * Class ShortcodeRequests
11
 * registers dependencies and loads resources for all requests where shortcodes may be present
12
 *
13
 * @package EventEspresso\core\domain\entities\routing\handlers\shared
14
 * @author  Brent Christensen
15
 * @since   \$VID:$
16
 */
17
class ShortcodeRequests extends Route
18
{
19
20
    /**
21
     * returns true if the current request matches this route
22
     * child classes can override and use Request directly to match route with request
23
     * or supply a RouteMatchSpecification class and just use the below
24
     *
25
     * @return bool
26
     * @since   $VID:$
27
     */
28
    public function matchesCurrentRequest()
29
    {
30
        return $this->request->isFrontend() || $this->request->isIframe() || $this->request->isAjax();
31
    }
32
33
34
    /**
35
     * @since $VID:$
36
     */
37
    protected function registerDependencies()
38
    {
39
        $this->dependency_map->registerDependencies(
40
            'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled',
41
            ['EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache]
42
        );
43
        $this->dependency_map->registerDependencies(
44
            'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout',
45
            ['EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache]
46
        );
47
        $this->dependency_map->registerDependencies(
48
            'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees',
49
            ['EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache]
50
        );
51
        $this->dependency_map->registerDependencies(
52
            'EventEspresso\core\domain\entities\shortcodes\EspressoEvents',
53
            ['EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache]
54
        );
55
        $this->dependency_map->registerDependencies(
56
            'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou',
57
            ['EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache]
58
        );
59
        $this->dependency_map->registerDependencies(
60
            'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector',
61
            ['EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache]
62
        );
63
        $this->dependency_map->registerDependencies(
64
            'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage',
65
            ['EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache]
66
        );
67
    }
68
69
70
    /**
71
     * implements logic required to run during request
72
     *
73
     * @return bool
74
     * @since   $VID:$
75
     */
76
    protected function requestHandler()
77
    {
78
        // load, register, and add shortcodes the new way
79
        $this->loader->getShared(
80
            'EventEspresso\core\services\shortcodes\ShortcodesManager',
81
            [
82
                // and the old way, but we'll put it under control of the new system
83
                EE_Config::getLegacyShortcodesManager(),
84
            ]
85
        );
86
        return true;
87
    }
88
}
89