elliot-sawyer /
silverstripe-matomo
| 1 | <?php |
||||
| 2 | namespace ElliotSawyer\Matomo; |
||||
| 3 | |||||
| 4 | use SilverStripe\Control\Director; |
||||
| 5 | use SilverStripe\Core\Extension; |
||||
| 6 | use SilverStripe\SiteConfig\SiteConfig; |
||||
|
0 ignored issues
–
show
|
|||||
| 7 | use SilverStripe\View\ArrayData; |
||||
| 8 | use SilverStripe\View\Requirements; |
||||
| 9 | use SilverStripe\View\SSViewer; |
||||
| 10 | |||||
| 11 | class MatomoExtension extends Extension { |
||||
| 12 | public function onAfterInit(&$controller) |
||||
|
0 ignored issues
–
show
The parameter
$controller is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||
| 13 | { |
||||
| 14 | $matomoCode = $this->getMatomoCode(); |
||||
| 15 | if($matomoCode) { |
||||
| 16 | Requirements::customScript($matomoCode, true); |
||||
|
0 ignored issues
–
show
true of type true is incompatible with the type integer|string expected by parameter $uniquenessID of SilverStripe\View\Requirements::customScript().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 17 | } |
||||
| 18 | } |
||||
| 19 | |||||
| 20 | public function getMatomoCode() |
||||
| 21 | { |
||||
| 22 | //check dev |
||||
| 23 | // if(Director::isDev() && !$this->config()->show_on_dev) { |
||||
| 24 | // return false; |
||||
| 25 | // } |
||||
| 26 | // //check test |
||||
| 27 | // if(Director::isTest() && !$this->config()->show_on_test) { |
||||
| 28 | // return false; |
||||
| 29 | // } |
||||
| 30 | // //check live |
||||
| 31 | // if(Director::isLive() && !$this->config()->show_on_live) { |
||||
| 32 | // return false; |
||||
| 33 | // } |
||||
| 34 | //check excluded controllers |
||||
| 35 | //check excluded URLs |
||||
| 36 | //check member opt-out |
||||
| 37 | |||||
| 38 | //still here? render the template |
||||
| 39 | $config = SiteConfig::current_site_config(); |
||||
| 40 | //check MatomoTrackingURL and MatomoSiteId |
||||
| 41 | return SSViewer::execute_template('Matomo', ArrayData::create([ |
||||
| 42 | 'MatomoTrackingURL' => $config->MatomoTrackingURL, |
||||
| 43 | 'MatomoSiteId' => $config->MatomoSiteId, |
||||
| 44 | ])); |
||||
| 45 | } |
||||
| 46 | } |
||||
| 47 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths