Passed
Push — v1 ( 2a4f93...bf6c9c )
by Andrew
07:11 queued 04:13
created

Manifest::getModule()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Twigpack plugin for Craft CMS 3.x
4
 *
5
 * Twigpack is the conduit between Twig and webpack, with manifest.json &
6
 * webpack-dev-server HMR support
7
 *
8
 * @link      https://nystudio107.com/
9
 * @copyright Copyright (c) 2018 nystudio107
10
 */
11
12
namespace nystudio107\twigpack\services;
13
14
use nystudio107\twigpack\Twigpack;
15
use nystudio107\twigpack\helpers\Manifest as ManifestHelper;
16
17
use craft\base\Component;
18
19
/** @noinspection MissingPropertyAnnotationsInspection */
20
21
/**
22
 * @author    nystudio107
23
 * @package   Twigpack
24
 * @since     1.0.0
25
 */
26
class Manifest extends Component
27
{
28
    // Public Methods
29
    // =========================================================================
30
31
    /**
32
     * Return the HTML tags to include the CSS
33
     *
34
     * @param string     $moduleName
35
     * @param bool       $async
36
     * @param null|array $config
37
     *
38
     * @return null|string
39
     * @throws \yii\web\NotFoundHttpException
40
     */
41
    public function getCssModuleTags(string $moduleName, bool $async = false, $config = null)
42
    {
43
        $settings = Twigpack::$plugin->getSettings();
44
        $config = $config ?? $settings->getAttributes();
45
46
        return ManifestHelper::getCssModuleTags($config, $moduleName, $async);
47
    }
48
49
    /**
50
     * Return the HTML tags to include the JavaScript module
51
     *
52
     * @param string     $moduleName
53
     * @param bool       $async
54
     * @param null|array $config
55
     *
56
     * @return null|string
57
     * @throws \yii\web\NotFoundHttpException
58
     */
59
    public function getJsModuleTags(string $moduleName, bool $async = false, $config = null)
60
    {
61
        $settings = Twigpack::$plugin->getSettings();
62
        $config = $config ?? $settings->getAttributes();
63
64
        return ManifestHelper::getJsModuleTags($config, $moduleName, $async);
65
    }
66
67
    /**
68
     * Return the Safari 10.1 nomodule JavaScript fix
69
     *
70
     * @return null|string
71
     */
72
    public function getSafariNomoduleFix()
73
    {
74
        return ManifestHelper::getSafariNomoduleFix();
75
    }
76
77
    /**
78
     * Return the URI to a module
79
     *
80
     * @param string $moduleName
81
     * @param string $type
82
     * @param null   $config
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $config is correct as it would always require null to be passed?
Loading history...
83
     *
84
     * @return null|string
85
     * @throws \yii\web\NotFoundHttpException
86
     */
87
    public function getModule(string $moduleName, string $type = 'modern', $config = null)
88
    {
89
        return ManifestHelper::getModule($config, $moduleName, $type);
90
    }
91
92
    /**
93
     * Invalidate the manifest cache
94
     */
95
    public function invalidateCaches()
96
    {
97
        ManifestHelper::invalidateCaches();
98
    }
99
}
100